Random Quote Machine and Twitter

Hey, I’m trying to make my random quote machine share the current quote to twitter as a tweet, but I’m stuck and don’t know how to move forward. My variable does not get passed into the text when I try to set my href attribute equal to “https://www.twitter.com/intent/tweet?text={myVariable}” . Whenever twitter would get opened the tweet would be “{myVariable}” What can I do ?

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36.

Challenge: Build a Random Quote Machine

Link to the challenge:

1 Like

Could you try this?

‘https://www.twitter.com/intent/tweet?text=${myVariable}’

It still isn’t working, here’s a link to the my code: https://codepen.io/Maco-t/pen/QWGZWZd?editors=0010

Sorry I don’t really have an answer for you. but I do have a question.

Are you using css inside your Javascript?

Yeah, why do you ask?

1 Like

I asked because Im in the process of learning Javascript, though I am aware of the fact that you can manipulate css with javascript; I didn’t really know that one could essentially style an entire page with javascript alone! this is really exiting!

1 Like

Add a variable below author that uses a template literal, e.g.

const url=`https://www.twitter.com/intent/tweet?text=${quote}`

You have to use backticks. (`)

Then use this variable.

Works just fine:

https://twitter.com/intent/tweet?text=Be%20not%20afraid%20of%20greatness.%20Some%20are%20born%20great,%20some%20achieve%20greatness,%20and%20others%20have%20greatness%20thrust%20upon%20them.
3 Likes