如果/不工作! PLZ HALP! [英] If/else not working! PLZ HALP!
本文介绍了如果/不工作! PLZ HALP!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨!所以我在下面的JS代码中遇到了一个问题。我的if / else语句只显示If的oeramiter,即使我输入了123456.
var age = ;
window .prompt( 多大年纪你呢?, 50 );
if (age< 23 ){
window .alert( 在学校或大学里玩得开心! 跨度>);
}
else {
window .alert( 尽情享受你所做的一切!);
}
我该怎么做才能使这项工作?
请快点帮忙,因为我正处于这个项目的最后期限。
我尝试了什么:
我已经尝试了许多提示,因为我认为这是问题,但是IDK sooooooooooooooo
解决方案
< blockquote>你没有分配年龄,试试这个:
var age = ;
age = window.prompt( 你多大了?, 50 跨度>);
if (age < 23 ){
window.alert( 在学校或大学里玩得开心! 跨度>);
}
else {
window.alert( 做一个有趣的一天做任何事情!);
}
Hi! So I came across a problem in the JS code below. My if/else statement will only show the oeramiter for "If", even when I put in 123456.
var age = "";
window.prompt("How old are you?", 50);
if (age < 23) {
window.alert("Have fun at school or in college!");
}
else {
window.alert("Have a fun day doing whatever you do!");
}
What do I do to make this work?
Please help quickly, as I'm on a bit of a deadline for this project.
What I have tried:
I have tried many things with the prompt as I think that that is the issue, but IDK sooooooooooooooo
解决方案
You're not assigning age, try this:
var age = ""; age = window.prompt("How old are you?", 50); if (age < 23) { window.alert("Have fun at school or in college!"); } else { window.alert("Have a fun day doing whatever you do!"); }
这篇关于如果/不工作! PLZ HALP!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文