If else statement


#1

In this chapter whenever according to the chapter {https://www.codecademy.com/courses/learn-javascript/lessons/control-flow/exercises/comparison-operators-ii?action=lesson_resume&link_content_target=interstitial_undefined}
here it was always if statement run whether i change the value from full to any other like half or any other string but its o/p always shows “Howllll!!!” but i can’t run the else statement. pls suggest some instructions so i can run the else part here is my code::

var moonPhase = “full”;
if (moonPhase = “full”) {
console.log(“Howwwwlll!!!”);
} else {
console.log(“I swear I am not a warewolf…”);
}


#2

If you if-statement always picks the same branch, then that says something about the condition you’re using.
So how does one test if two values are equal?


#3

Hi @webace18314 ,

You forgot to write “if (moonPhase === ‘full’”! I am almost sure that’s the problem. I have made this mistake too. I hope that this helps.


#4

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