语法错误:意外的令牌其他 [英] Syntax Error: Unexpected token Else

查看:324
本文介绍了语法错误:意外的令牌其他的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过Codecademy学习Javascript,在这里没有被困过.

I am learning Javascript via Codecademy and no have been stumped on this little piece here.

我应该写一个if else语句.

I have supposed to write an if else statement.

在下面的代码中,它向我显示语法错误,缺少标识符:

It shows me here in the following that there is a Syntac Error with a missing identifier:

var userAnswer = prompt("Are you feeling lucky, punk?");

if (userAnswer === "yes");
{

    console.log("Batman hits you very hard. It's Batman and you're you! Of course Batman wins!");
}

 else {

    console.log("You did not say yes to feeling lucky. Good choice! You are a winner in the game of not getting beaten up by Batman.");
}

这有什么问题....在此示例中没有错误:

What is wrong with that.... There is no error in this example here:

if (age < 18)

{

    console.log("We take no actions or responsibility. Play at your own risk!");
}

else

{

    console.log("Enjoy the game");
}

推荐答案

if (userAnswer === "yes");

删除分号.

这篇关于语法错误:意外的令牌其他的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆