Sleep Debt Calc Step 12 (not covered by video tutorial)

Hey folks. Struggling to get past the final step in the sleep debt calculator project.

In particular, the second bullet point of step 12 says “Some people need to sleep longer than others. Rewrite getIdealSleepHours() so that you can pass it as an argment, like getIdealSleepHours(8) where 8 is the ideal hours per night. Update the call to getIdealSleepHours() in calculateSleepDebt() too.”

Everything worked in the project until this final step and I followed the ‘Hint’, which basically provided the answer, but I’m still getting a 'SyntaxError of “Unexpected token const” around calculateSleepDebt = () => {

I copy my code below for reference.

Any help is gratefully recieved.

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

const getIdealSleepHours = idealHours => idealHours * 7;
}

const calculateSleepDebt = () => {
  const actualSleepHours = getActualSleepHours();
  const idealSleepHours = getIdealSleepHours(8); 
    if (actualSleepHours === idealSleepHours) {
      console.log('Great job! You got the perfect amount of sleep.')
    } else if (actualSleepHours > idealSleepHours) {
        console.log('You got ' + (actualSleepHours - idealSleepHours) + ' more hour(s) sleep than you needed this week.')
    } else if (actualSleepHours < idealSleepHours) {
      console.log('You need to get some rest. You got ' + (idealSleepHours - actualSleepHours) + ' fewer hours sleep than you needed this week.')
    }
    }

calculateSleepDebt();


1 Like

Fixed it! erroneous } after const getIdealSleep Hours.

Silly me :crazy_face:

2 Likes

Rock on! :rocket: