No errors, but nothing is produced into the console when I execute this… What am I missing and how can I debug in the future?
const getSleepHours = day => {
if (day === 'Monday') {
return 7;
} else if (day === 'Tuesday') {
return 7;
} else if (day === 'Wednesday') {
return 7;
} else if (day === 'Thursday') {
return 7;
} else if (day === 'Friday') {
return 8;
} else if (day === 'Saturday') {
return 8;
} else if (day === 'Sunday') {
return 7;
}
}
const getActualSleepHours = () =>
getSleepHours('Monday') + getSleepHours('Tuesday') + getSleepHours('Wednesday') + getSleepHours('Thursday') + getSleepHours('Friday') + getSleepHours('Saturday') + getSleepHours('Sunday');
const getIdealSleepHours = () => {
const idealHours = 8;
return idealHours * 7;
}
const calculateSleepDebt = () => {
const actualSleepHours = getActualSleepHours();
const idealSleepHours = getSleepHours();
if (actualSleepHours === idealSleepHours) {
console.log('You got the perfect amount of sleep.');
} else if (actualSleepHours > idealSleepHours) {
console.log('You got ' + (idealSleepHours + actualSleepHours) + ' hour(s) more sleep than you needed this week. Get some rest.');
} else if (actualSleepHours < idealSleepHours) {
console.log('You got ' + (idealSleepHours - actualSleepHours) + ' hour(s) less sleep than you needed this week. Get some rest.');
} else {
console.log('Error');
}
};
calculateSleepDebt();
https://www.codecademy.com/courses/introduction-to-javascript/projects/sleep-debt-calculator