Can't get this quote generator to work?

This is my random quote generator:

For some reason, the tweet button only works when I put the variable randomNumber outside of the function randomQuote(), and a quote doesn’t show up when the page first loads. Any ideas on what may be causing these problems? I would greatly appreciate the help.


That is because you defined randomNumber locally inside the function randomQuote. Outside that function, randomNumber is undefined.

That is because you only execute randomQuote when the button is clicked. If you want to load a quote when the page loads, try executing the function somewhere outside the event handlers.

Thank you so much for your reply! I was able to fix it.