Twitter button to my random quote machine stuck

Twitter button to my random quote machine stuck
0.0 0


having some trouble figuring out my twitter button on the random quote machine any help will help with the hair loss


Please provide a link so we can see the code.



First of all, I think the url you’re looking for is "" it is text, not message.

Second, I found it better to handle this in a click handler, like you did with newQuote() but for a tweet. I had a line:"" + text + ";hashtags=" + hashtags, "width=500,height=300");
to handle it in my JS.


i made the changes but it still only opens a blank tweet no quote in there.?


When I change your html for the tweet to "" it does send it to the tweet window.

But again, that isn’t how I’d handle it - I’d handle it in the JS.

You added `“” + text + “;hashtags=” + hashtags, “width=500,height=300”);’ but there are two problems with that. Firstly, it isn’t wrapped in any function, like newQuote() is. Secondly, the variables text and hashtags aren’t defined. You don’t need the hashtags, but you need to define text somehow in a variable to which the tweet function has access.

Next, seeing the statement `’ leads me to think that you are cutting and pasting from somewhere else.

In short, you need to do what you did with the newQuote button. First you need the html. For the quote button you have:

<center><button id= btn onclick= "newQuote()">New Quote</button></center>

(Although that id should be in quote and should be unique.)
You need to duplicate that for the tweet button with the appropriate changes.

Then you need to add a function to your JS. For the quote button, you have:

function newQuote(){
  var randomNumber = Math.floor(Math.random () * (quotes.length));
  document.getElementById ('quoteDisplay').innerHTML= quotes[randomNumber];

You need to create a function like this, but to handle the tweet button. It’s name will be whatever function you call in the html. But of course, you will call the tweet window. And you’ll need to have a way to get the text of the quote. Your randomNumber is local to the newQuote() function so you might make that global by declaring it outside the function.