sleepCheck


#1

So, probably right in front of my eyes, but I am having a similar problem, can someone tell me why this isn't working?:
var sleepCheck = function(numHours) {
if (numHours >= 8) {;
return "You are getting plenty of sleep!";
else {;
return "Get some shut-eye!";
};
sleepCheck(9)

Much appreciated, thanks.
EDIT: So, it says there is an error in syntax, and doesn't run. When I remove some semicolons, it says 'unexpected token else', but what does that mean?

EDIT2: Ok, got it to work, however, now I realize another quandary, why doesn't it work when I put a prompt before the if function begins to ask how many hours the user is getting, and then setting this prompt variable equal to numHours? Thank you.


PLEASE HELP my code is not working
#2

if you want to use a prompt, store the result of the prompt in a variable, and supply this variable as argument when calling the function


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.