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 trialgiorgio gristina
Front End Web Development Techdegree Graduate 13,839 PointscorrectGuess does not change to true
let correctGuess = false;
const number = 8;
const guess = prompt("guess a number between 1 and 10");
if (+guess == number) {
currentGuess = true;
}
if (correctGuess) {
console.log(`u ve guessed the number`);
} else {
console.log(`The number was ${number}`);
}
it always log on the console The number was 8
1 Answer
Jennifer Nordell
Treehouse TeacherHi there, giorgio gristina! It looks like you're doing well here. And you're really close. However, it seems like somewhere you may have changed your mind about what to name your variable.
if (+guess == number) {
currentGuess = true;
}
But I'm pretty sure you meant:
if (+guess == number) {
correctGuess = true;
}
Note the difference between currentGuess
and correctGuess
.
Hope this helps!
giorgio gristina
Front End Web Development Techdegree Graduate 13,839 Pointsthank u so much Jennifer Nordell, I really appreciated and u re right infact i realized the mistake. sorry for the silly mistake.
giorgio gristina
Front End Web Development Techdegree Graduate 13,839 Pointsgiorgio gristina
Front End Web Development Techdegree Graduate 13,839 Pointsbtw FYI the backticks are in the console log but they dont appear in the code when i copied.