+ 1
Why is this not working?
Whenever I put 5 and 10 as the two numbers (others too) it will give an incorrect output. Also, when the two numbers are equal it will say NaN https://code.sololearn.com/W8mNcns0Kc1v/?ref=app
8 Respuestas
+ 4
Oh wait. Wait. Wait. I got the problem.
Your numbers are not numbers (as in integers), they are strings!
+ 3
When numbers are inputted the program works fine.
What you have handled wrongly is the no input case.
If (num1)||(num2==NaN) is what your 3rd condition does. You need to do:
if (num1==NaN||num2==NaN)
+ 3
Jack Rehfeldt Look at my edited answer
+ 2
I remember one neat "hacks" which is simply,
add a +
Edit:
var prompt1 = +prompt("Hey");
var prompt2 = +prompt("There");
Like that
+ 1
⏩ Prometheus ⏪ try putting 5 in first then 10. it says 10 is smaller
+ 1
⏩ Prometheus ⏪ how would i turn them into integers?
would i do it like:
if(int(prompt1) < int(prompt2){} or?
+ 1
⏩ Prometheus ⏪ im confused? what?
+ 1
⏩ Prometheus ⏪ Works! Thank you for your help!