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];
}
$("#getMessage").click(function(){
var textToTweet= quote;
var tweetLink = 'https://twitter.com/intent/tweet?text=' + quote; encodeURIComponent(textToTweet);
window.open(tweetLink,’_blank’);});
Thank you a lot! It’s working. I was trying to use var textToTweet=quotes[randomNumbers] but it was bad idea . 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.
Thanks!
I try to make it as simple a possible and with JS only i’m glad that i helped someone with this