Unexpect token in JavaScript 2 exercise 12


#1

can anyone help me find my unexpected token


#2

I apologize but what lesson is this @kimothekat?


#3

Nevermind @kimothekat I found it, it was 12, the Community Manager changed it to "123" which confused me.


#4

// Write your function below.
// Don't forget to call your function!
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);

Now @kimothekat your issue seems to be when you forgot to put

var sleepCheck = function(numHours); {

Which resulted in a unexpected "}" token because it did not know what "}" was supposed to close
Also do not forget to put an extra "}" after you put the "{" after the function


#5

Also I do not know if this was purposeful or not but @albionsrefuge if your edit was supposed to be a joke I highly believe that you should be marked down a rank for changing the exercise number from 12 to 123 because that really confused me in the response to @kimothekat. If it is accidental I apologize for what I have just said.


#6

It was indeed accidental. I was moving the post to the category called:

3 Introduction to Functions in JS

and I typed a 3 in the wrong place.

Thank you for kindly pointing it out.


#7

@albionsrefuge I believe that mistake should not be allowed to a person of such high ranking as you but again I do not make the rules of these forums.


#8

And now I hope that you are joking. :green_heart:


#9

Why do you hope I am joking @albionsrefuge?


#10

This is not a place where mistakes are forbidden. Everyone makes mistakes. Mistakes are just learning opportunities.


#11

I will not argue with you for I partly agree with what you are saying @albionsrefuge, the only part I do believe is that mistakes here are meant for people who code incorrectly and do not know what they did wrong, not for people of high trust levels in the forum that make a mistake in editing someone's post so that people may properly answer them and help them understand what they did wrong.


#12

Many Thanks! code is working and I'm off to rock paper scissors


#13

@kimothekat You are very welcome!