Sleep Debt Calculator - Accept Upper or Lower Case

Hi there,

New to posting into the forums & have a quick question.

I seem to run into the issue of putting capitals on my strings for particular words as that’s what I’d normally do, however H & h are not the same thing in Javascript & I want to prevent this issue by using the .toLowerCase function as this would hopefully eliminate this issue.

I’ve tried to use the same .toLowerCase() from the rock, paper, scissors game but it keeps giving me errors on the Sleep Debt Calculator.

Can someone help me here.

const getSleepHours = day => {  

  day = day.toLowerCase();

  switch (day) {

    case 'monday':

      return 8;

        break;

    case 'tuesday':

      return 7;

        break;

    case 'wednesday':

      return 8;

        break;

    case 'thursday':

      return 5;

        break;

    case 'friday':

      return 4;

        break;

    case 'saturday':

      return 6;

        break;

    case 'sunday':

      return 4;

        break;

    default:

      return 'error';

        break;

  }

};

/* 

Used to test the above function is working:

console.log(getSleepHours('wednesday'));

*/

const getActualSleepHours = () => {

  return getSleepHours('monday') + getSleepHours('tuesday') + getSleepHours('wednesday') + getSleepHours('thursday') + getSleepHours('friday') + getSleepHours('saturday') + getSleepHours('sunday')

};

console.log(getSleepHours('monday'));

console.log(getActualSleepHours());

You have chosen the correct method. Consider how you are using it. Might not be the problem. Keep that in mind.