Sleep Calculator Error (other forums not helping)


#1

Hey everyone,

I am currently working my way through the Sleep Calculator program, but I’m coming across an error. I double checked for spelling, spacing, and brackets. Can anyone tell me what’s wrong? Thanks you for your time.
–Bryan

const getSleepHours = day => {
if (day === ‘monday’) {
return 8;
} else if (day === ‘tuesday’) {
return 8;
} else if (day === ‘wednesday’) {
return 8;
} else if (day === ‘thursday’) {
return 7;
} else if (day === ‘friday’) {
return 7;
} else if (day === ‘saturday’) {
return 8;
} else if (day === ‘sunday’) {
return 7;
}

const getActualSleepHours = () => {
getSleepHours(‘monday’) +
getSleepHours(‘tuesday’) +
getSleepHours(‘wednesday’) +
getSleepHours(‘thursday’) +
getSleepHours(‘friday’) +
getSleepHours(‘saturday’) +
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 enough sleep’);
}
else if (actualSleepHours > idealSleepHours) {
console.log(‘You got more than the required sleep’);
}
else {
console.log(‘You did not get enough sleep’);
}
};

calculateSleepDebt();


#2

Please describe the error, and post a link to the project.


#3

You have some missing and misplaced brackets:
Here:

and here:


#4

We can analyze your code and maybe point out inconsistencies and syntax errors, but we still have no context. Please post the URL of the lesson or this topic will be closed.