Skip to content
Advertisement

Comparing number always return false

I generate a random number with an interval and then I check if the number chooses by the user is the same, but it always returns false

JavaScript
JavaScript

Advertisement

Answer

Remove the rndNumber from function CheckNumber(rndNumber) { because that is actually the click event on the checkButton

Also a good idea to cast to number since .value is a string.

The == will cast for you but it is no longer up to you then

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement