Sleep Debt Calculator gives me undefined

**function getSleepHours(day){
switch (day) {
case ‘Monday’:
return 8;
break;
case’Tuesday’:
return 6;
break;
case’Wednesday’:
return 5;
break;
case’Thursday’:
return 7;
break;
case’Friday’:
return 5;
break;
case’Saturday’:
return 9;
break;
case’Sunday’:
return 7;
break;
}
}

const getActualSleepHours = () =>
{
return getSleepHours(‘Monday’) + getSleepHours(‘Tuesday’) + getSleepHours(‘Wednesday’) + getSleepHours(‘Thursday’) + getSleepHours(‘Friday’) + getSleepHours(‘Saturday’) + getSleepHours(‘Sunday’)
}

const getIdealSleepHours = () =>
{
let 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’)
} else if (actualSleepHours >>> idealSleepHours) {
console.log(‘You got more sleep than required’)
} else if (idealSleepHours >>> actualSleepHours) {
console.log(‘You need more sleep. Go rest up’)
}

}

console.log(calculateSleepDebt());
**

Why does this output undefined in the terminal? Any help?strong text

calculateSleepDebt function doesn’t return anything, yet when calling the function, you log the returned result.

either let calculateSleepDebt function return the string you want to log, or don’t log the returned result

I have now called the function at the end instead of logging it however, the terminal is not outputting anything?

can i see the code? Because currently, i don’t know what you did.

function getSleepHours(day){
  switch (day) {
    case 'Monday':
    return 8;
    break;
    case'Tuesday':
    return 6;
    break;
    case'Wednesday':
    return 5;
    break;
    case'Thursday':
    return 7;
    break;
    case'Friday':
    return 5;
    break;
    case'Saturday':
    return 9;
    break;
    case'Sunday':
    return 7;
    break;
  }
}

const getActualSleepHours = () =>
{
 return getSleepHours('Monday') + getSleepHours('Tuesday') +  getSleepHours('Wednesday') + getSleepHours('Thursday') + getSleepHours('Friday') + getSleepHours('Saturday') + getSleepHours('Sunday')
}

const getIdealSleepHours = () =>
{
  let 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');
  } else if (actualSleepHours > idealSleepHours) {
    console.log( 'You got more sleep than required');
  } else if (idealSleepHours > actualSleepHours) {
    console.log('You need more sleep. Go rest up');
  }

}

calculateSleepDebt();

what is the problem? I ran your code here:

https://jsbin.com/kicacebihi/edit?js,console

and everything looks fine?

Okay so i did what you said but I’m not sure if you see but i also changed the >>> to > and it worked because of that. I wanted to ask now, what is the difference between the >>> and > operators?

>>> is a bitwise operator:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators