Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
This video covers one solution to the first part of the "Number Guessing Game" challenge.
Resources
while
loop solution
Review how you might write the number guessing program using a while
loop.
const main = document.querySelector('main');
const randomNumber = getRandomNumber(10);
let guess;
function getRandomNumber(upper) {...}
while ( parseInt(guess) !== randomNumber ) {
guess = prompt('I am thinking of a number between 1 and 10. What is it?');
}
main.innerHTML = `<h1>You guessed the number! It was ${randomNumber}.</h1>`;
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
CLAUDIU CHIOREAN
Front End Web Development Techdegree Student 9,368 PointsMy solution with easy changeable values option.
1 Answer
-
Gal Parselany
Full Stack JavaScript Techdegree Graduate 26,281 Points0 Answers
-
Kirok James
Full Stack JavaScript Techdegree Student 876 Points2 Answers
-
Frank Malcov
Full Stack JavaScript Techdegree Student 38 Points1 Answer
-
Kelsey Donegan
3,342 Points1 Answer
-
Esther AlQaisi
2,311 Points1 Answer
-
Zoltán Erkel
6,340 Points1 Answer
-
Daniel Statsenko
Full Stack JavaScript Techdegree Student 4,235 Points1 Answer
-
Thomas Chisum
1,762 Points1 Answer
View all discussions for this video
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up