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
sulaiman abouabdah
5,314 Pointstrying different code for do...while video
var randomNumber = getRandomNumber(10);
var guess;
var guessCount = 0;
function getRandomNumber( upper ) {
var num = Math.floor(Math.random() * upper) + 1;
return num;
}
do {
guess = prompt("I am thinking of a number between 1 and 10. What is it?");
guessCount +=1;
} while (parseInt(guess) ==! randomNumber)
document.write("<p>You have guessed the Random number:" + randomNumber + "</p>");
document.write("<p>It took you " + guessCount + " guesses to get it write.</p>")
I tried the previous code for https://teamtreehouse.com/library/do-while-loops-2 It is different than what is written in the video but I would like to know what is wrong with my code
1 Answer
Steven Parker
243,656 PointsThe type-sensitive inequality operator is "!==", but the code here has "==!" instead (equality combined with negation).
And while it doesn't affect program operation, the word "right" is shown as "write".