我的代码在var myAge(第一行)的某个地方出现问题。我已经加载了浏览器,但无法打开提示窗口。关于代码有什么问题的任何想法?
<script>
var myAge = parseInt( prompt("enter your age", 30), 10 );
if (myAge >= 0 && myAge <= 10) {
document.write("myAge is between 0 and 10 <br/>");
}
if ( !(myAge >= 0 && myAge <= 10) {
document.write("myAge is NOT between 0 and 10 <br/>");
}
if (myAge >= 80 || myAge <= 10) {
document.write("myAge is 80 or above OR 10 or below.<br/>");
}
if ( (myAge >= 30 && myAge <= 39) || (myAge >= 80 && myAge <= 89) ) {
document.write("myAge is between 30 and 39 and 39 or myAge is " + "between 80 and 88");
}
</script>
答案 0 :(得分:1)
你在第二个if块中错过了一个paranthesis .....也关闭了脚本标签。
var myAge = parseInt( prompt("enter your age", 30), 10 );
if (myAge >= 0 && myAge <= 10) {
document.write("myAge is between 0 and 10 <br/>");
}
if ( !(myAge >= 0 && myAge <= 10)) {
document.write("myAge is NOT between 0 and 10 <br/>");
}
if (myAge >= 80 || myAge <= 10) {
document.write("myAge is 80 or above OR 10 or below.<br/>");
}
if ( (myAge >= 30 && myAge <= 39) || (myAge >= 80 && myAge <= 89) ) {
document.write("myAge is between 30 and 39 and 39 or myAge is " + "between 80 and 88");
}