Coding Manifestation Logo
Lesson 1

What is a Variable?

A variable is a named location in memory that stores a value. You can think of it as a labeled box that holds data.

25age

Imagine you have boxes to store information.

NameVivek
Age29
CityHosur
1let age = 25;2let name = "Vivek";3const country = "India";45console.log(age);      // 256console.log(name);     // Vivek7console.log(country);  // India
Output
25
Vivek
India
Variable NameValue in Memory
age25
name"Vivek"
country"India"
  • let 123name = "John";

    Variable names cannot start with numbers.

  • const age = 25;age = 30;

    Constants cannot be reassigned.

let firstName;let totalPrice;const PI = 3.14;

Use meaningful names and follow naming conventions.

  • What is a variable?
  • Difference between let, const and var.
  • Swap two numbers without using a third variable.
  • Create three variables and print themEasy
  • Swap two numbersEasy
  • Calculate total marks of 3 subjectsMedium
  • Convert temperature from Celsius to FahrenheitMedium
  • Simple interest calculatorHard
2 min

Which keyword is used to declare a constant?

PrevNext