(SOLVED) 7/11 Else if Statements : Practice 2 Error - Console will not log string


#1

https://www.codecademy.com/courses/learn-javascript-control-flow/lessons/control-flow/exercises/else-if?action=lesson_resume&course_redirect=introduction-to-javascript

This code is supposed to log Arms and legs are getting hairier to the console, however I keep receving this error:
/home/ccuser/workspace/learn-javascript-U2L1E5-8/main.js:8
} else if {
^
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)

What is going on here, and why is this not working? What is wrong with my code?


let moonPhase = 'mostly full';
if (moonPhase === 'full') {
  console.log('Howl!');
} else if (moonPhase === 'mostly full') {
  console.log('Arms and legs are getting hairier');
} else if (moonPhase === 'mostly new') {
  console.log('Back on two feet');
} else if {
  console.log('I swear I am not a werewolf.');
} else {
  console.log('Invalid moon phase');
}



#2

Hi @methodwhiz74990,

You’re missing a condition for your third else if, which is before the

console.log('I swear I am not a werewolf.');

Insert the appropriate condition according to the exercise then the code should work.


On side note: does the exercise require you to have a third else if?


#3

Thank you very much! I can not believe I was that blind. Thanks for the quick and helpful response! :slight_smile:
And no, it did not. It gave me code from exercise 6/11, which was unneeded.


#4

@methodwhiz74990, you’re welcome.

I actually haven’t done this new ES6 JS course up until just now, rushing up to the part of your question, good catch, the exercise only requires two else if statements.

I was pointing out why you caught the error because lacking a condition if you put a else if based on your code. :wink:


#5

Thanks again. I’ll have to remember this in the future. I have written it down in my notes I am taking. I’m trying to learn as much as possible. :smiley:


#6

Simple code mistakes will always be overlooked its good to step away and ask for another set of eyes :eyes: in a code review :+1:


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.