This is my first post on the community forum. If I missed anything from the guidelines about proper posting, please let me know and I will adjust to make it better.
I am currently working on the ‘Number Guesser’ project in JavaScript and I have my code done but not sure why its not working. Everything seems to be right? Here’s my code:
The code that calls your functions is in a file called game.js. The function below isn’t named correctly, and likely causes your game to crash. If you open your browser console, you should see an error like: Uncaught ReferenceError: advanceRound is not defined
=+ is not an operator. It is the assignment operator followed by a plus sign, so you are assigning your variables to a positive 1. If you want to increment a variable, you have several options:
let myValue = 0;
//add 1:
myValue++;
//add 1 again:
myValue += 1;
//add 1 yet again:
myValue = myValue + 1;
//add a value other than 1:
myValue += 5
//or:
myValue = myValue + 5
Edit: Oops! Didn’t realize you had already updated your code to use variable++.
Edit #2: Didn’t look closely enough:
The above probably isn’t doing what you think it should be doing. Compare your code to my examples above. See Increment (++) - JavaScript | MDN for more information.
Here's a brief example of what happens when using the increment operator as you have above:
let x = 3;
x = x++;
console.log(x); //x is still 3
x = x++;
console.log(x); //what is printed?
x = x++;
console.log(x); //what is printed now?
Output:
3
3
3
If there are issues other than your scores and round number not updating, try opening your browser console. Refresh the page, and try playing the game. Do you see any error messages in the console?