Sleep Debt Calculator doesn't like ">" or "<" for some reason

First time doing anything with Javascript here!

When I try to add “>” or “<” to my code under the calculateSleepDebt function on the second else/if statement, it gives me an “unexpected token” error.

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

  }
};

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();

  if (actualSleepHours === idealSleepHours){
    console.log("You got the perfect amount of sleep!")
  };
//Why doesn't java like my greater/less than statements?
  else if (actualSleepHours > idealSleepHours){
    console.log("You got" + actualSleepHours - idealSleepHours + "hours of too much sleep" )
  };

  else if (actualSleepHours < idealSleepHours) {
    console.log("You need " + idealSleepHours-actualSleepHours + " more hours of sleep!")
  }
  
  else {console.log("Error, you blew it!")};

}

Because of the semicolons that you use in the conditional statement.

if (condition) {
  // do stuff
} else if (another condition) {
  // do something else
} else {
  // do something else

Do you see it? :wink:

1 Like

I see! I deleted the semicolons and it works now!