Kindly help me to debug it

KINDLY HELP ME TO DEBUG IT.

const getSleepHours=day=>{
  switch (day) {
    case 'Saturday':
    return 1;
    break;
    case 'Sunday':
    return 2;
    break;
    case 'Monday':
    return 3;
    break;
    case 'Tuesday':
    return 4;
    break;
    case 'Wenesday':
    return 5;
    break;
    case 'Thursday':
    return 6;
    break;
    case 'Friday':
    return 7;
    break;
    default:
    return 'Error!'
  }
};
// console.log(getSleepHours('Tuesday'));
const getActualSleepHours=()=>{
  getSleepHours('Saturday')
  +getSleepHours('Sunday')
  +getSleepHours('Monday')
  +getSleepHours('Tuesday')
  +getSleepHours('Wednesday')
  +getSleepHours('Thursday')
  +getSleepHours('Friday');
};
console.log(getActualSleepHours()); // should print the sum of all sleep hours in the week
const getIdealSleepHours=()=>{
  let idealHours=6;
  return idealHours*7
};
console.log(getIdealSleepHours()); // if idealHours is 7, should print 42

const calculateSleepDebt=()=>{
  let actualSleepHours= getActualSleepHours();
  let actualIdealHours=getIdealSleepHours();
};
if (actualSleepHours === actualIdealHours) {
  console.log('the user got the perfect amount of sleep');
} else if (actualSleepHours > actualIdealHours) {
  console.log('You got ' + (actualSleepHours - idealSleepHours ) + ' hour(s) less sleep than you needed this week.');
} else {
  console.log('You got ' + (idealSleepHours - actualSleepHours) + ' hour(s) less sleep than you needed this week. Get some rest.');
}
calculateSleepDebt();



Hi @randmebgmail.com
welcome to the forum.
Can you describe your problem, please?

2 Likes

One thing I notice is there isn’t a return inside of the getActualSleepHours function. Is this intentional?

Yes @codeneutrino it is intentional.

What day? :wink:
Also, as @codeneutrino pointed out:

The above function doesn’t return anything. You’re somewhere between an arrow function and a concise body arrow function. Choose one or the other.

Also here:

  • It appears you closed the body of your function prematurely.
  • Where is idealSleepHours defined?
1 Like