Javascript

please I have bugs but don’t know where?

const getSleepHours = day => {
switch (day) {
case’monday’:
return 8
break;
case ‘tuesday’:
return 7
break;
case ‘wenesday’:
return 7
break;
case ‘thusday’:
return 7
break;
case ‘friday’:
return 7
break;
case ‘saturday’:
return 7
break;
case ‘sunday’:
return 7
break;
default :
return “Error!”
}
};

const getActualSleepHours = () =>
getSleepHours(‘monday’) +
getSleepHours(‘tuesday’) +
getSleepHours(‘wenesday’) +
getSleepHours(‘thurdday’) +
getSleepHours(‘friday’) +
getSleepHours(‘saturday’) +
getSleepHours(‘sunday’);

console.log(getSleepHours(‘monday’));
console.log(getActualSleepHours());

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

const calculateSleepDebt = () => {
const actualSleepHours =
getActualSleepHours();
const getIdealSleepHours =
getIdealSleepHours();

if (actualSleepHours === idealSleepHours)
{
console.log(“You’ve got the perfect amount of sleep!”);
}
else if (actualSleepHours > idealSleepHours){
console.log(“you’ve got” + ( actualSleepHours - idealSleepHours) + “more hours of sleep this week”);
}
else if(actualSleepHours < idealSleepHours) {
console.log(“You should get some rest because you’ve slept” + (idealHours - actualSleephours) + " hours less than you should have tjis week");
}

else {
console.log(“Error! Something went wrong, check your code.”);
}
};

calculateSleepDebt();

Hey @vuthy1983! How you doing?
I may be able to help you, but please post your code formatted as requested by the guidelines.

You can do this either by:

  • adding three backticks ``` in newlines before and after your code block
  • or simply copypaste your code inside the <code> tags when you create a Codebyte.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.