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

correctGuess 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

btw FYI the backticks are in the console log but they dont appear in the code when i copied.

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi 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! :sparkles:

thank u so much Jennifer Nordell, I really appreciated and u re right infact i realized the mistake. sorry for the silly mistake.