[英]Why doesn't this code work? (on HTML format)
Why doesn't this code work? 为什么这段代码不起作用? My visual studio code is telling me that the "else" in "else if" has declaration or statement expected.
我的视觉工作室代码告诉我“else if”中的“else”具有预期的声明或声明。 my script:
我的剧本:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
var a = 1+1;
var y = 1.5*2
if (a = 2){
for (var i = 0; i<5; i = i + 2){
document.write("Hello "+ i +" Everyone.</br>")
} else if (y=3){
for (var j = 2; j < 10; j = j+3){
document.write("Hey there.")
}
}
}
</script>
</body>
</html>
https://i.stack.imgur.com/Gwc1c.png https://i.stack.imgur.com/Gwc1c.png
Your code didn't work for a couple of reasons: 您的代码无法正常工作,原因如下:
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <script type="text/javascript"> var a = 1+1; var y = 1.5*2 if (a === 2) { for (var i = 0; i<5; i = i + 2) { document.write("Hello "+ i +" Everyone.</br>") } } else if (y === 3) { for (var j = 2; j < 10; j = j+3){ document.write("Hey there.") } } </script> </body> </html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.