Issues with Sleep Debt Project

I’m having issues with the sleep debt project.

This is my code:

const getSleepHours = (day) => {
  if (day === 'monday') {
    return 8;
  } else if (day === 'tuesday') {
    return 7;
  } else if (day === 'wednesay') {
    return 6;
  } else if (day === 'thursday') {
    return 7;
  } else if (day === 'friday') {
    return 5;
  } else if (day === 'saturday') {
    return 7;
  } else if (day === 'sunday') {
    return 4;
  } 
}

const getActualSleepHours = () => 
  getSleepHours('monday') + 
  getSleepHours('tuesday') + 
  getSleepHours('wednesday') + 
  getSleepHours('thursday') + 
  getSleepHours('friday') + 
  getSleepHours('saturday') + 
  getSleepHours('sunday');


console.log(getSleepHours('tuesday'));
console.log(getActualSleepHours());

The getSleepHours function works. But for getActualSleepHours I only get back NaN and I can’t figure out why : /

1 Like

Hey there @maddoxgrey42!! Welcome to the Codecademy forums :grinning:

You’re first function works because you are using a return statement, however your getActualSleepHours returns nothing so there is nothing to use console.log() on.

Hmm…so I was trying to use implicit return which according to the video associated with the lesson doesn’t require a return statement. But even if I don’t use implicit return and add back the curly braces and the return at the beginning. It’s the same result, NaN.

Hi @maddoxgrey42,
Check your first function aka “getSleepHours”, There is a Typo, right? [And It makes Coercion into play for second function]
Nothing wrong with your second function tho as It is explictely returning value.

1 Like

Argh. Stupid ‘wednesay’

Thanks @greentreemee !!!

1 Like

Yeah, :+1:No Worries, Keep up the good work! :grinning: