If else with two conditions


#1

My Code - this is working fine.



var moonPhase = "full";
var foggyNight = false;
if (moonPhase === "full" || foggyNight) {
  console.log('Howww111!!');
} 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");
}


But if I use extra brackets for easy understanding, I am getting an error message.



if ((moonPhase === "full") || (foggyNight)) {
  ......

Can someone please help me understand the issue?


#3

Is the error from the SCT or the console?


#4

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