如果是意外的令牌

时间:2015-12-30 20:41:32

标签: javascript

我是JS codecademy课程的初学者。超级基础,我知道。它一直告诉我意外的令牌,如果我一直试图调试这几个小时。请帮忙?提前谢谢!

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!";
}

2 个答案:

答案 0 :(得分:4)

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!";
    }
}

你错过了{}

答案 1 :(得分:2)

您的功能似乎没有用花括号包裹。

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!";
}
}

应该有效。 欢迎!