Help me i got a syntax error and I'm not sure what I missed

This is my code I know im missing something but i cant tell what.

const getSleepHours= (day) =>

{if(day===‘monday’) {return 8}

else if(day===‘tuesday’) {return 7}

else if(day=== ‘wednsday’) {return 6}

else if(day=== ‘thursday’) {return 5}

else if(day === ‘friday’) {return 4}

else if(day === ‘saturday’) {return 3}

else if(day === ‘sunday’) {return 2}}

}

The problem is your quotation mark.

const getSleepHours = day => {
if (day === ‘monday’) {
return 8;
}
else if (day === ‘tuesday’) {
return 7;
}
else if (day === ‘wednsday’) {
return 6;
}
else if (day === ‘thursday’) {
return 5;
}
else if (day === ‘friday’) {
return 4;
}
else if (day === ‘saturday’) {
return 3;
}
else if (day === ‘sunday’) {
return 2;
}
};

Not sure but can you try

Hello @odunsi, welcome to the forums! I should imagine the speech marks are correct-they’ve just be formatted incorrectly in the forums. Visit ->this<- thread to see how to correctly format your code in posts.


The error might be because you have one too many closing curly braces } at the end of your code:

else if(day === ‘sunday’) {return 2}}
                                    ^
                                    | _ _ _ _ _ _ 
                                                 \
                                                  \
}<--this throws the error, as you already have two here

I hope this helps!

1 Like