Hello all,
I am on step 5 and using if/else method.
However, the randomNumber keeps showing Unexpected identifier.
Can anyone help?
Hello all,
I am on step 5 and using if/else method.
However, the randomNumber keeps showing Unexpected identifier.
Can anyone help?
You need to wrap your conditional statement in parentheses, i.e., if (randomNumber === 0)
Hello NET,
Thanks for helping. However, I still have one question.
I was on the last step and used upper case BOMB in the IF and it shows ERROR.
I thought it should be changed to lower case automatically since we have .toLowerCase()
Can you please explain why it shows ERROR ?
whatever string is in userInput
would be changed to be lowercase
because of userInput = userInput.toLowerCase();
if userInput
is 'BOMB'
, then userInput
would become 'bomb'
however,
doing userInput === 'BOMB'
does not change that 'BOMB'
to lowercase because the 'BOMB'
on that line was not stored in the userInput
variable.
So it should be userInput === 'bomb'
since userInput
was changed to lowercase earlier.
userInput === 'BOMB'
would always be false
since userInput
can’t have any uppercase letters anymore (it was changed to be all lowercase earlier).