Else if error( Did you write an else statement that logs 'Invalid moon phase'?)


#1

My code:

let moonPhase=“nofull”;
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
{
console.log(“Invalid moon phase”);
}

any help???


#2

Yes, link to the exercise please.

We need to be able to see what’s precisely being asked.


#3

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


#4

When copy/pasting your code, the quotation marks that you use don’t recognize the strings.

Yours appear like this: “ Howl! ”
When they should appear like this: " Howl! "

Once I changed that everything worked fine. What kind of keyboard are you using (country)?

Edit: My bad, it doesn’t work fine. You need to structure your code.

if (condition) {
  console.log(something);
}
else if (other condition) {
  console.log(something);
}
else {
  console.log(something);
}

#5

i m currently using a dell laptop.


#6

Anyway, the underlying problem here is the structure of the code, as per my example.

Did you get it to work?


#7

No its not working!!!


#8

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