+ 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!") };
3 ответов
0
sorry but i am not understand 😂
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.
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