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

JavaScript JavaScript Loops, Arrays and Objects Simplify Repetitive Tasks with Loops `do ... while` Loops

the random number

So does every time a random number generates and then every time i try to guess a new number? What i mean is does the random number stay the same from the first time the browser generates a random number and then i try to guess that number, or does it change every time i get it wrong?

1 Answer

andren
andren
28,558 Points

The random number is only generated when the getRandomNumber function is called, which only happens at the very start of the script.

When you load the page a random number is assigned to the randomNumber variable, and then after that your guess is compared to that stored number. It does not change after you make a guess.

Thank you!