Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Nathan Marshall
6,031 PointsWhat would be a good way to approach this?
Hi Guys,
I am currently creating a random quote generator. I was wondering what would be the best way to show one quote at a time on my page. I have all of my quotes in an array. I am displaying the quotes from the array based off of a random number that I have created.
Here is my CodePen: https://codepen.io/Nathan-Callum-Marshall/pen/rrapGQ
Help would be appreciated thanks,
Nathan
1 Answer
Steven Parker
243,656 PointsOne easy technique would be to hide all the quotes right before you display the new one in"showQuote":
for (q of quotes) q.style.display = "none";
Nathan Marshall
6,031 PointsNathan Marshall
6,031 PointsThanks, Steven Parker. I didn't know that you could declare the contents of an array as a variable like that.