SleepDebtCalculator

Hey there,

Im new to coding. At the moment I am stuck at the SleepDebtCalculator from the Introduction to Javascript course. My code is like this and it keeps saying Unexpected token ) . I checked my code several times but I don’t know where the problem is.:

const getSleepHours = day => {
   
switch(day) {
  case 'monday':
    return 8
    break;
  case 'tuesday':
    return 7
    break;
  case 'wednesday':
    return 8
    break;
  case 'thursday':
    return 5
    break;
  case 'friday':
    return 8
    break;
  case 'saturday':
    return 8
    break;
  case 'sunday':
    return 8
    break;
   }
}

const getActualSleepHours = () => {
getSleepHours('monday') + 
getSleepHours('tuesday') + 
getSleepHours('wednesday') + 
getSleepHours ('thursday') + 
getSleepHours ('friday') + 
getSleepHours ('saturday') + 
getSleepHours ('sunday');
  
}

console.log(getSleepHours('monday'));

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

const calculateSleepDebt = () => {
  const actualSleepHours = getActualSleepHours();
  const idealSleepHours = getIdealSleepHours();
  if (actualSleepHours === idealSleepHours) {
    console.log(actualSleepHours === idealSleepHours);
  } else if (actualSleepHours > idealSleepHours) {
    console.log(actualSleepHours > idealSleepHours);
  }

Thanks in advance for helping me!

1 Like

at the getActualSleepHours function, don’t use line brakes, just add them like:

And at the calculateSleepDept function you forgot to close a {} bracket

Hope this helps :grinning:

1 Like