Welcome to the Treehouse Community
Looking to learn something new?
Jeremy Coleman5,449 Points
Phrase or Quote on Refresh?
I know what I want, not sure how to code it or what to look for. Basically, I want for example 10 phrases or quotes but only 1 of those 10 will randomly appear on the website. It changes upon refresh.
Bonus to this would to add a button just the phrase refreshes and not the entire website. Can anyone point me in the right direction for this? Thank you!
Three hits for this. Do not want to give you to much.
1.You are going to need a randoms number. (Math.random()) 2.Some way to store the quotes in your code and a way to get them with a number. 3.And a function combining those two elements and to call the function when the button gets pressed.
Let me know if you want more hints but see what you can come up with.
Jason Desiderio21,811 Points
Jeremy Coleman - Here is a video lesson describing pretty much what you are looking for. It chooses a random word (which you can change to phrases) from an array and displays it on the page when the button is pressed. You'll be able to modify it to run on page load as well as on the button click event.
Hope this helps!