bhylu.com

Advertisements

JS Mistakes

Assignment inside a condition can look like a comparison. Use a clear boolean expression and inspect unexpected branches.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

let status = "closed";
if (status === "open") {
  console.log("Book now");
}
console.log(status);

What happens

The branch is skipped and status remains closed.