+ 1

why always "you are old enought!"?

prompt ("how your age?") var age=("prompt") if("age > 18"){ alert ("you are old enought!") } else { alert ("you are not allowed!") };

1st Nov 2016, 6:38 AM
Rajiph iqbal ghandi
Rajiph iqbal ghandi - avatar
3 ответов
0
sorry but i am not understand 😂
1st Nov 2016, 6:49 AM
Rajiph iqbal ghandi
Rajiph iqbal ghandi - avatar
0
var age=prompt ("how your age?"); if(age >= 18){ alert ("you are old enought!") } else { alert ("you are not allowed!") }; in your code the problem was that You were writing the condition between " so what You where saying was if true so it says You are old enought always.
1st Nov 2016, 7:58 AM
Esteban Juarez Rodriguez
Esteban Juarez Rodriguez - avatar
0
Quotes are for string usage only, which doesn't have a boolean(true/false) value itself, but if you remove the quotes it will no longer be a string but a number comparison (which is what you'd want in this situation
1st Nov 2016, 11:38 AM
somestuffontheinternet
somestuffontheinternet - avatar