Twitter button in Quote generator

Hello guys.
I don’t know what shoudl i call in my var textToTweet to get my quote shared on twitter.

Hi @GrzeluD,
you could store the displayed quote in a seperate variable (i.e quote) and then pass that variable into the twitter link
var quote;
function randomQuote() {
var randomNumber = Math.floor(Math.random()*(quotes.length))

document.getElementById(‘quoteDisplay’).innerHTML = quotes[randomNumber];
quote = quotes[randomNumber];

var textToTweet= quote;

  var tweetLink = '' + quote; encodeURIComponent(textToTweet);,’_blank’);});

1 Like

Thank you a lot! It’s working. I was trying to use var textToTweet=quotes[randomNumbers] but it was bad idea :stuck_out_tongue:. One more time Thanks !

After looking at dozens of codepen for this assignment, trying to get the Twitter feature to work, yours finally made sense to me.


1 Like

I try to make it as simple a possible and with JS only :slight_smile: i’m glad that i helped someone with this :slight_smile: