cf.completefrontend

Predict the outputMedium

What does this log when a function declares a var inside an if (false) block?

What does this log?
var color = "red";
 
function paint() {
  console.log(color);
  if (false) {
    var color = "blue";
  }
  console.log(color);
}
 
paint();
console.log(color);

The answer

Work out every line it logs, in order. Then check.

Checking your sign-in…