12.functions &if/else


#1


#2

Try to use diffrent browsers if you can since this is a :bug: (update me with results):


#3

it's not working in other browser.


#4

in your if statement you have:

return "You are getting plenty....

this should be:

return You're getting plenty....

i highly recommend copy this kind of strings from the instructions, since they are really strict on punctuation.


#5

Haha I love the tab in the screenshot that says "How to Take a Screenshot"


#6

Hi all. My syntax seems to be wrong, but I'm not sure where the error is:

var sleepCheck = function(numHours);
if(numHours >= 8) {
return "You're getting plenty of sleep! Maybe even too much!";
} else {
return "Get some more shut eye!";
}
sleepCheck(10);
sleepCheck(5);
sleepCheck(8);

I've tried typing the same syntax as on the screenshot above, but it's not working.


#7

Hey @irena01! Your suppose to have brackets starting and ending the function. SO a function looks like this:

var sleepCheck = function(numHours){
//Code
}

Hope this helped!


#8

Hey @amanuel2
It helped me. Thank you!


#9

Honestly, I wish more people used the snipping tool! It's SO much easier (IMO) than an entire screen grab, but it doesn't seem to be common!


#10

Yea, totally agree. I set up my print screen keys in the following way:
print screen -> capture entire screen
ctrl + print screen -> give me the snippet tool
shift + print screen -> make print screen of active window
ctrl + shift + print screen -> give me all possible options

I love it, so much easier


#11

I am getting a different error and my code looks exactly like yours.


#12

Next time use the snipping tool, you can select the section you want instead of the entire screen. Or the prntscr will just save to your onedrive. Win+PrntScr will save to screenshots in the Pictures folder.


#13

delete the semicolons after the curly brackets in the if/else statement


#14

Yeah got it working. Codeacademy told me to put do it but I never did it until this lesson.


#15

the problem in the first image, is that you used ) to close { for if and else, that is not going to work:

if (something){
   // some code
) <- this should be a }

#16

boss you wrote You are instead of You're. the console have been programmed to accepted a particular text other than that is an error boss