I don't get any output from my code

Hi guys. I’m learning JavaScript and I’m not getting any output when I’m doing projects. At this moment I’m doing Sleep Debt Calculator and I can’t see anything on right hand side as output. Only if I have any errors they are there. In function ‘getActualSleepHours’ at the end I have 2 console.log lines and there’s nothing printing out.

This is my code atm :

const getSleepHours = day => {
if(day === ‘monday’) {
return 8;
}
else if(day === ‘tuesday’) {
return 9;
}
else if(day === ‘wednesday’) {
return 7;
}
else if(day === ‘thursday’) {
return 10;
}
else if(day === ‘friday’) {
return 8;
}
else if(day === ‘saturday’) {
return 10;
}
else if(day === ‘sunday’) {
return 7;
}
};
const getActualSleepHours = () => {
getSleepHours(‘monday’)

  • getSleepHours(‘tuesday’)
  • getSleepHours(‘wednesday’)
    + getSleepHours(‘thursday’)
    • getSleepHours(‘friday’)
    • getSleepHours(‘saturday’)
    • getSleepHours(‘sunday’)

console.log(getSleepHours(‘monday’));
console.log(getActualSleepHours());
}

This is link to project:
https://www.codecademy.com/courses/introduction-to-javascript/projects/sleep-debt-calculator

Welcome to the forums!

When sharing code please do so according to this post: https://discuss.codecademy.com/t/how-do-i-format-code-in-my-posts, it makes it much easier to identify what the issue is :slightly_smiling_face:.

That said, it doesn’t look like you are ever printing anything inside of, or returning anything from, getActualSleepHours() which is the function meant to give output, you’ll want to return the sum of the calls to getSleepHours() so that they are printed. It also looks like the final two console.log statements are inside of the function, you would want to have it outside otherwise you may cause an infinite loop from the function calling itself repeatedly.

1 Like