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 A Closer Look at Loop Conditions

Fuad Muhammad
Fuad Muhammad
4,273 Points

Where the 'guess' get the guess?

How the 'guess'/computer get the number to the guess? We can see on the text editor, the 'guess' is empty. And it must guess the number that will be out on the randomNumber function.

Is the computer get have the number itself on this device, or it get number from the random on the system, or javascript that make it happen.

Please explain me about what I asking. Don't explain too much. Thanks...

1 Answer

Umesh Ravji
Umesh Ravji
42,386 Points

Hi Fuad, without explaining too much, the guess variable is set in the while loop by obtaining a value from the getRandomNumber() function.

while ( guess !== randomNumber ) {
    guess = getRandomNumber( upper );
}
Fuad Muhammad
Fuad Muhammad
4,273 Points

Whataheck, It is not unthinkable by me before. Lol. Thank you so much, Umesh Ravji.