Functions & If/Then Else-Different Error


#1

I am doing the sleepCheck lesson and can not figure out what I am doing wrong. I've looked at the code over and over and it matches others' posts that work. What am I missing? All statements end with ; where appropriate and all curly brackets are in matching pairs. I'm perplexed.

Here is the error: ReferenceError: sleepcheck is not defined

Here is my code:

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);
sleepCheck(5);
sleepCheck(8);


#2

your code is fine, try a different browser. This will give you a new connection, could be your browser was sending cached data


#3

I had been using Firefox. Tried the same code in Chrome (which I had
never used for CodeAcademy) and I get the same error. Cleared the cache
on both browsers and still get the same error. Something strange is going on. I can't get past or get credit for that lesson.


#4

But the code is perfect, i made sure of it. Uhm.. i will ask around


#5

take a screenshot and post it here
@bsalle2


#6

Screenshot:

I even tried cutting the code, pasting it into notepad, hit the "reset code" button, and then pasting the code that should work back into the javascript window. I still get the error. Clearing the cache does not fix it, different browsers does not fix it. It looks like there may be some server side profile issue here.


#7

problem is last one
sleepCheck not sleepcheck
@bsalle2


#8

Nice catch :slight_smile: But in the earlier code bsalle posted:

sleepcheck was spelled correctly.