#12 Functions and if/else


Replace this line with your code.


// Write your function below.
// Don't forget to call your function!
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);

What is wrong with this? The console box says: syntaxerror: expected expression, got keyword "if"


Your function syntax is off. It should look something like:

var anyword = function(parameters) {
code here for what the function does
more code
a little more code

Learn more here:



Thank you! That worked.


I have the same problem.


hey @sparta99, can you post your code in a new topic? be more than happy to help either way :slight_smile:


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