What's wrong with this code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What's wrong with this code?

I enter 153 as first number. And 5 as second number. But it alerts"second number is greater". var m1=prompt("Enter First Number"); var m2=prompt("Enter Second Number"); if (m1>m2) { alert("First one is greater"); } else if(m1<m2) { alert("Second one is greater"); } else { alert("Equal"); }

8th Feb 2021, 4:52 PM
Morteza Mohammadi
Morteza Mohammadi - avatar
2 Answers
+ 1
or implicitly convert to number: m = +prompt();
8th Feb 2021, 5:01 PM
visph
visph - avatar
0
Thank you
8th Feb 2021, 6:20 PM
Morteza Mohammadi
Morteza Mohammadi - avatar