Tweeting Quotes [SOLVED]

Tweeting Quotes [SOLVED]
0

#1

I need some help on my quote generator. I have the quotes generating just fine. However, I can’t seem to get the tweeting right. The way I did it was by taking my quote, splitting the string in an array, joining it using “+” signs, and then appending it to https://twitter.com/intent/tweet?text=. I know this is a weird way to do it, but it’s the way that made the most sense to me. Why isn’t it working (the button is not even showing up)? You can find my Codepen here:
http://codepen.io/ZZBrent/pen/Wpzday

Thank you for any help and advice you can give!


#2

Here I corrected your code:

...
...
document.getElementById("click").innerHTML = `<button id='tweetQuote' onClick=(tweet(randQuote))>Tweet it!</button>`;
}

function tweet(randQuote) {
  randQuote = 'https://twitter.com/intent/tweet?text=' + randQuote
  window.open(randQuote);
}

#3

Thank you! It’s working now! All I need to do now is use CSS to style.

Thank you so much! I really appreciate the help!