Sleep Debt Calculator

Hi everyone,
Having some issues with the Sleep Debt Calculator project.

I have finished the steps, but I get a syntax error. See code and syntax error below.

const getSleepHours = day => {
switch(day) {
case ‘Monday’:
return = 4;
break;
case ‘Tuesday’:
return = 3;
break;
case ‘Wednesday’:
return = 4;
break;
case ‘Thursday’
return = 7;
break;
case ‘Friday’
return = 8;
break;
case ‘Saturday’
return = 10;
break;
case ‘Sunday’
return = 10;
break;
}
};
const getSleepHours = day => {

};
const getActualSleepHours = () => {
getSleepHours(‘Monday’)

  • getSleepHours(‘Tuesday’)
  • getSleepHours(‘Wednesday’)
  • getSleepHours(‘Thursday’)
  • getSleepHours(‘Friday’)
  • getSleepHours(‘Saturday’)
  • getSleepHours(‘Sunday’)
    };
    const getIdealSleepHours = () => {
    const idealHours = 8;
    return idealHours * 7;
    };
    const calculateSleepDebt = () => {
    const actualSleepHours = getActualSleepHours();
    const idealSleepHours = getIdealSleepHours();
    };
    console.log(if actualSleepHours === idealSleepHours {
    console.log(‘Got right sleep!’);
    } else if (actualSleepHours > idealSleepHours) {
    console.log(‘You got ’ + (actualSleepHours - idealSleepHours) + ’ hour(s) more sleep than needed. Not too bad!’););
    } else if (actualSleepHours < idealSleepHours) {
    console.log(‘You got ’ + (idealSleepHours - actualSleepHours) + ’ hour(s) less sleep than needed. Sleep some more’);
    }
    calculateSleepDebt();

Syntax Error:

/home/ccuser/workspace/sleep-debt-calculator/sleepDebtCalculator.js:4
return = 4;
^
SyntaxError: Unexpected token =
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)

You have getSleepHours declared twice for one. Your syntax error message is telling you exactly where your error is.

case ‘Monday’:
return = 4;

is incorrect. You aren’t assigning (=) return a value. You are returning that value from the function

case ‘Monday’:
return 4;
2 Likes

Thanks! That makes sense.