# Sleep Debt Calculator

Hello,

I’ve got a syntax error “SyntaxError: Unexpected identifier” for project: https://www.codecademy.com/courses/introduction-to-javascript/projects/sleep-debt-calculator

I starts from the if statement : if (actualSleepHours === idealSleepHours)
I’m not sure why? If anybody can help me.

``````const getSleepHours = day => {

if (day === 'Monday') {
return 8;
}
else if (day === 'Tuesday') {
return 7;
}
else if (day === 'Wednesday') {
return 7;
}
else if (day === 'Thursday') {
return 7;
}
else if (day === 'Friday') {
return 9;
}
else if (day === 'Saterday') {
return 7;
}
else if (day === 'Sunday') {
return 7;
}
else {
}
};

const getActualSleepHours = () =>
getSleepHours('Monday') +
getSleepHours('Tuesday') +
getSleepHours('Wednesday') +
getSleepHours('Thursday')  +
getSleepHours('Friday') +
getSleepHours('Saterday') +
getSleepHours('Sunday');

const getIdealSleepHours = () => {
let idealHours = 8;
return idealHours * 7;
};

const calculateSleepDebt = () => {
const actualSleepHours = getActualSleepHours ();
const idealSleepHours = getIdealSleepHours ();
}

if (actualSleepHours === idealSleepHours)
{
console.log('you got the perfect amount of sleep')
}
else if (actualSleepHours > idealSleepHours)
{
console.log('You got ' + (idealSleepHours - actualSleepHours) + ' hour(s) less sleep than you need this week. Get some rest')
}
else if (actualSleepHours > idealSleepHours) {
console.log('You got ' + (idealSleepHours-actualSleepHours) + ' more sleep than needed')
}
else {
console.log ('Error!')
}

}

calculateSleepDebt ();
``````

here:

``````}

calculateSleepDebt ();
``````

if i put my cursor on the `}` it becomes red, indicating it doesn’t have a matching opening curly bracket.

If you indent your code nicely, it becomes a lot easier to spot this kind of error.

1 Like

Thanks! When I remove the }, I’ve got another error “ReferenceError: actualSleepHours is not defined”
But I did created a variable actualSleepHours.

yes, but what scope does that variable have and where do you try to access this variable?

your `calculateSleepDebt` function ends too early/you close the function too early

2 Likes

okay thanks for pointing this out