Help with Sleep Debt Calculator

Please can someone help me with this Error Message that this Code Creates: I just can’t see it for the life of me!

const getSleepHours = (day) => {

switch (day) {

case “Monday”:

return 6;

break;

case “Tuesday”:

return 6;

break;

case “Wednesday”:

return 7;

break;

case “Thursday”:

return 7;

break;

case “Friday”:

return 8;

break;

case “Saturday”:

return 7;

break;

case “Sunday”:

return 9;

break;

default:

return “Error.”

}

};

//console.log(getSleepHours(“Sunday”));

const getActualSleepHours = () => {

getSleepHours(“Monday”)

  • getSleepHours(“Tuesday”)

    • getSleepHours(“Wednesday”)

      • getSleepHours(“Thursday”)

        • getSleepHours(“Friday”)

          • getSleepHours(“Saturday”)

            • getSleepHours(“Sunday”)

}

//because this function doesn’t have a parameter, (see these brackets are full in the first function but empty in the second) we do not need to pass in an argument. I.e what this means is, getActualSleepHours added up the totals from each day. and Remember, if there’s no parameter value, it will not be required to get the result in the log.

const getIdealSleepHours = () => {//NewFunctionNme

let idealHours = 7// Created New Variable.

return idealHours * 7;// Aplied Maths to it.

};

const calculateSleepDebt = () => {//L" NewV

let actualSleepHours = getActualSleepHours();

const idealSleepHours = getIdealSleepHour();

// const idealSleepHours also nV

if(actulaSleepHours === idealSleepHours){ console.log( “You done Good.”);

}

else if(actualSleepHours > idealSleepHours){console.log(“You done Bad!”)}

}

else if(actualSleepHours < idealSleepHours){console.log(“Kick back and chill. You work too Hard”)

}

else { console.log(“Error. Something went wrong. Check Your Code.”) // This else statment will get evaluated if none of the previous conditions are true.

}

};

console.log(calculateSleepDebt());

Please format your code using the </> button so that it will be more readable for someone trying to help out.

Additionally, posting the error message you got would also help. They contain useful information to help identify where there’s a problem in your code.

1 Like