Introduction

A variable gives a name to a value. Choose names that describe the information, such as score or learner_name. Assign a value before you read it, and remember that assigning again replaces the previous value.

Syntax & example

const name = "Developer";
console.log("Hello", name);

Expected output

Hello Developer

Common mistakes

  • Using a variable before assigning a value to it.
  • Mixing text and numbers without converting deliberately.
  • Skipping an empty input or a boundary value when testing.

Practice

Create a variable for your favorite city and display it.

13px
main.jsYour ideas, in code.
Loading your editor…
Run your code to see the output here.
Ready to buildUTF-82 lines