Just a quick question about control flow coding


#1

doing my first exercise about if/else something called my atention…

let isSoccerFan = false;

if (isSoccerFan = false) {console.log(“No Goal!”)}
else {console.log(“Goal!”)}

with only one sign “=” at “isSoccerFan=false” i get as result “No goal” in console as spected. but when I try with triple “===” as it shows in the example of the exercise (2/11) I get “Goal”.

It may be a dumb question


#2

The above is an assignment statement. isSoccerFan is set to false.

The above is a conditional expression that uses a comparison, so === is needed else it will raise an error.


#3

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