Mastery Points
0
Active Mission

Mission: Master the scoping rules of let vs const to earn points.

Objective: add N/A to the code

Current MissionIN PROGRESS

Riddle:Mission: Master the scoping rules of let vs const to earn points.

33%
Reward: 40 XP Verified

Variables and Constants in javascript

Context & Logic

JavaScript variables are used to store values in memory. Use let for reassignable values, const for values that should not be reassigned, and avoid var in modern code because of its function scope and hoisting quirks.

Example

let counter = 0;      // can be reassigned
const API_URL = "/api"; // should not be reassigned

// BAD: var is function‑scoped and hoisted
function demo() {
  console.log(x); // undefined
  var x = 10;
}

Prefer let and const for predictable block scoping; var behaves differently because it is function‑scoped and hoisted.

Test Your Knowledge

Assessment Mode
1Which keyword should be used for a value that should never change?