导致"语法错误的Javascript:意外的令牌:

时间:2014-06-29 02:54:20

标签: javascript

我正在学习Javascript,在将其放入后,会产生一个

SyntaxError: Unexpected token

错误消息。

这是我的代码:

 var sleepCheck = function sleepCheck(numHours);
    if numHours >= 8
    {
        return("You're getting plenty of sleep! Maybe even too much!");
    } else {
        return("Get some more shut eye!");
    };
    sleepCheck(10);

非常感谢任何帮助,谢谢:)

1 个答案:

答案 0 :(得分:0)

您应该阅读有关Javascript语法的内容。

这是我的更正:

var sleepCheck = function(numHours) {
  if (numHours >= 8) {
    return "You're getting plenty of sleep! Maybe even too much!";
  } else {
    return "Get some more shut eye!";
  }
};

sleepCheck(10);