Sleep Debt Calculator

You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

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

link to code: Hastebin: Send and Save Text or Code Snippets for Free | Toptal®

I am having difficutly understanding the error messages presented by javascript editor in codecademy. I have tried running it in visual studio code but it just tries to pull up a blank website. Can someone teach me how to interpret the error messages being presented. I need to know what line the code error is on. Also what is wrong with my code?

Code error presented:
/home/ccuser/workspace/sleep-debt-calculator/sleepDebtCalculator.js:19
});
^
SyntaxError: Unexpected token )
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)

You can post the code here in a formatted block rather than having to link to a 3rd party site.

function getSleepHours(day) {
  if(day === 'monday') { 
    return 8;
  } else if (day === 'tuesday'){
    return 8; 
  } else if (day === 'wednesday'){
    return 8;
  } else if (day === 'thursday'){
    return 8;
  } else if (day === 'friday'){
    return 8;
  } else if (day === 'saturday') {
    return 8;
  } else if (day === 'sunday') {
    return 8; 
  } else { return "invalid entry please choose a day of the week"
  }
  console.log(getSleepHours('monday'))

You are missing your final closing brace for the function

function getSleepHours(day) { if(day === 'monday') { return 8; } else if (day === 'tuesday'){ return 8; } else if (day === 'wednesday'){ return 8; } else if (day === 'thursday'){ return 8; } else if (day === 'friday'){ return 8; } else if (day === 'saturday') { return 8; } else if (day === 'sunday') { return 8; } else { return "invalid entry please choose a day of the week" } } console.log(getSleepHours('monday'))

how do I paste formatted code into this forum?

Can you teach me how to interpret the error messages? Can you show me where it says on what line there is an issue? Or does it not work that way?

The opening lines contain the most salient information for our purposes. All the other lines can be ignored.

The file path has a colon and number at the end. That is the line number where the error was triggered. The carat (^) indicates where parsing stopped.

2 Likes