+ 3

Hello guys,, why is this code displaying only the else (veteran) statement for all inputs

Number(prompt("How old are you??")) if(Number<=18){alert( "Up and coming"); } else{alert( "veteran!"); }

25th Apr 2017, 11:07 PM
LinusCaesar
LinusCaesar - avatar
4 Answers
+ 16
I think the problem is because you are using Number which is a function in the condition. What you should do: var num = Number(prompt("How old are you??")); if(num <= 18) alert("Up and coming") else alert("veteran")
25th Apr 2017, 11:45 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 13
your welcome @Linus
25th Apr 2017, 11:56 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 2
Thanks @Ulisses Cruz !
25th Apr 2017, 11:54 PM
LinusCaesar
LinusCaesar - avatar
0
Do you mind demonstrating..? @Meharban
25th Apr 2017, 11:24 PM
LinusCaesar
LinusCaesar - avatar