Sleep Dept Calculator: Syntax Error

I keep receiving a syntax error when I reach a certain point in the sleep debt calculator. I also keep receiving a syntax error telling me that the error is one line of code BELOW the total number of lines in my code editor (i.e. error will be on line 53, but I only have 52 lines of code visible). Below is my most recent code and error:

Here is my code:

const getSleepHours = day => {
  switch(day) {
    case 'monday':
      return 8
      break; 
    case 'tuesday':
      return 5
      break;
    case 'wednesday':
      return 6
      break;
    case 'thursday':
      return 4
      break;
    case 'friday':
      return 10
      break;
    case 'saturday':
      return 9
      break;
    case 'sunday':
      return 7
      break;
    default:
      return 'Error!';
  }
}; 

const getSleepHours = day => {

};

const getActualSleepHours = () => {

};


Here is the error:

/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/sleepDebtCalculator.js:31
};
^
SyntaxError: Identifier ‘getSleepHours’ has already been declared
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)

But you do have two getSleepHours. Try to delete this one:

const getSleepHours = day => {

};

Because you already got sleep hours here:

const getSleepHours = day => {
switch(day) {
case ‘monday’:
return 8
break;

You already declared this function and switched days, registering hours you got in every of those days.

1 Like

Thank you so much for your help! This worked and I’m very grateful!

1 Like