Siddharth Pandey4,184 Points
Why doesn't my app work?
This has nothing to do with Linking to sections of a webpage.
I was making my own simple program where the user guesses a number and the computer generates a number of the range the user chooses, but for some reason, my code is not working and the program is not running properly when the user's guess and the computers generated number are the same.
Here is a link to a snapshot of my code: https://w.trhou.se/bmfnwrkj3w
You can be sure it's not working by choosing the number the range to be to number 1, and also guessing number one, and the correct alert statement will not appear. Why is this?
Maxwell NewberryFront End Web Development Techdegree Student 7,675 Points
In your conditional statement, you have a triple equal sign. In other words, you're checking whether or not the guess is identical (strict equal) to the random number generated. What you want is two equal signs, or checking whether the random number is equal (loose equal) to the guess.
You can read the documentation on that here.
But essentially, loose equal (equal,
perform a type conversion when comparing two things, and will handle NaN, -0, and +0 specially to conform to IEEE 754 (so NaN != NaN, and -0 == +0);
Whereas strict equal (identical,
will do the same comparison as double equals (including the special handling for NaN, -0, and +0) but without type conversion; if the types differ, false is returned.
KRIS NIKOLAISENPro Student 51,733 Points
In order to update userGuess with parseFloat() you would need to reassign with: userGuess = parseFloat(userGuess)