28 Conclusion part 2


if (“6+2=8”);
console.log(“I finished my first course!”)

What’s wrong with this ?


==== 1 =======
The semi-colon is used by Javascript to express an END-of-Statement

if (“6+2=8”);

the Javascript Interpreter will see it as the END of the IF-statement
you will therefor run into the error that the ELSE-statement is NOT recognized as being part of an IF-ELSE statement.

===== 2 ========
In your if (condition)
Normally you use a comparison using one or more logical operators…
which will then evaluate to a true or false

You are using a string
then the Javascript will create a truthy or falsy

  • A falsy value is a value that translates to false when evaluated in a Boolean context
  • In JavaScript, a truthy value is a value that is considered true when evaluated in a Boolean context. All values are truthy unless they are defined as falsy (i.e., except for false, 0, “”, null, undefined, and NaN).



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