// var yourID = userinput =>{}
const getSleepHours = day => {
day = day.toLowerCase();
// switch works like if statement but is shorter
switch(day){
case 'monday':
return 8;
case 'tuesday':
return 8;
case 'wednesday':
return 8;
case 'thursday':
return 5;
case 'friday':
return 3;
case 'saturday':
return 11;
case 'sunday':
return 6;
default:
return 'Error!';
}
}
// This is the user input if we asked for it
const getActualSleepHours = () =>
getSleepHours('Monday')+
getSleepHours('Tuesday')+
getSleepHours('Wednesday')+
getSleepHours('Thursday')+
getSleepHours('friday')+
getSleepHours('saturday')+
getSleepHours('sunday');
//Ideal Sleep is 8 hours * 7 days
const getIdealSleepHours = () =>{
const idealHours = 8;
return idealHours*7
};
// Here we are calling getActualSleepHours and getIdealSleepHours and assigning them ...nfc why.
const calculateSleepDebt = ()=>{
const actualSleepHours =
getActualSleepHours();
const idealSleepHours =
getIdealSleepHours();
if (actualSleepHours === idealSleepHours) {
console.log((idealSleepHours-actualSleepHours)+' Hours, Great Job! you got enough sleep');
}
else if (actualSleepHours > idealSleepHours) {
console.log('Maybe time for a social life');
}
else {
console.log('Nap time!');
}
calculateSleepDebt();
}
Hi so i have been through my code and through the video and when i run this code i get no output. I am assuming from what i can see it is because i am missing console log statements earlier in the code but i am not sure. Could someone nudge me in the right direction please.
Also why are we taught function prefix if everything uses a const/let?