有人能纠正这个代码吗?

Can anyone correct this code?

本文关键字:代码      更新时间:2023-09-26

我无法执行此代码。我试了很多次,但都没有成功。

<html>
<head><title>
alvin</title>
<script type = "text/javascript">
var voting age = window.prompt("please enter your age");
if(voting age>=18)
{
    document.write("you are eligible to vote");
}
else
{
    document.write("you are not eligible to vote");
}
</script>
</head>
</html>

冷静点孩子不要在考试紧张时紧张你唯一需要知道的是变量不能有空间所以我把voting age换成了voting_age

<html>
<head><title>
alvin</title>
<script type = "text/javascript">
var voting_age = window.prompt("please enter your age");
if(voting_age>=18)
{
    document.write("you are eligible to vote");
}
else
{
    document.write("you are not eligible to vote");
}
</script>
</head>
</html>