Control Flow: Werefolf (else if) exercise not accepting nested ternary operators


#1

The lesson won’t let me past step 1, even though the code does what was asked.

Lesson in question:
https://www.codecademy.com/courses/learn-javascript/lessons/control-flow/exercises/else-if?action=lesson_resume

There are no proper error messages. My code behaves as it is supposed to.
The lesson, however, says i failed, and gives me this message: “Did you write an else if statement for if the moonPhase is mostly new?”

Here is my code:



var moonPhase = 'full';

  moonPhase === 'full' ? console.log('Howwwwlll!!')
: moonPhase === 'mostly full' ? console.log('Arms and legs are getting hairier')
: moonPhase === 'mostly new' ? console.log('Back on two feet')
: console.log('Invalid moon phase');



#2

We are asked to follow the instructions given. That means using: if, else if and an else statement. Do you know how to do this? Example:

if (that === that) {
//we can use console.log(); here.
}

#3

These ternary operators act as if/else/else if statements. When I tried using them in earlier exercises, they let it pass.


#4

I know, but they want us to do it the way they Codecademy wants to. (with the statements and such)


#5

Ok. I still find it strange that they would let me use them in the other exercises where we were asked to use if/else, but not this one.


#6

Yeah, its odd. :confused: But if you have experience with this language, then doing this should be a breeze. :slight_smile:


#7

Yeah. Just submitted using normal if/else if/else.


#8

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