出于某种原因,意外的令牌不断返回。有关如何解决它的任何想法?
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!";
}
答案 0 :(得分:3)
javascript中的函数有{
和}
的正文分隔符:
var sleepCheck = function(numHours) { // <-- START HERE
if (numHours>=8)
{
return "You're getting plenty of sleep! Maybe even too much!";
}
else
{
return "Get some more shut eye!";
}
}; // <-- END HERE
答案 1 :(得分:1)
你的语法错了。试试这个:
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!";
}
};