🔹 1. Variables
Variables are used to store data.
✅ var
- Old way to declare variables
- Function-scoped (not block-scoped)
var name = "Aditya";
✅ let
- Modern way (recommended)
- Block-scoped
- Value can be changed
let age = 25;
age = 30;
✅ const
- Block-scoped
- Value cannot be reassigned
const pi = 3.14;
🔹 2. Data Types
📌 String
Text values
let name = "Aditya";
📌 Number
Numbers (integer or decimal)
let marks = 95;
let price = 99.99;
📌 Boolean
True or False
let isLogin = true;
📌 Undefined
Variable declared but not assigned
let x;
📌 Null
Empty value (intentionally)
let data = null;
📌 Object
Collection of key-value pairs
let user = {
name: "Aditya",
age: 25
};
📌 Array
List of values
let fruits = ["Apple", "Banana", "Mango"];
🔹 3. Operators
➕ Arithmetic Operators
Used for calculations
let a = 10;
let b = 5;console.log(a + b); // 15
console.log(a - b); // 5
console.log(a * b); // 50
console.log(a / b); // 2
🔍 Comparison Operators
Compare values (returns true/false)
console.log(10 == "10"); // true (loose)
console.log(10 === "10"); // false (strict)
console.log(10 > 5); // true
🔗 Logical Operators
Used with conditions
let age = 20;console.log(age > 18 && age < 30); // true
console.log(age > 18 || age < 10); // true
console.log(!(age > 18)); // false
📝 Assignment Operators
Assign values
let x = 10;
x += 5; // x = x + 5 → 15
x -= 2; // 13
🔹 4. Type Conversion
📌 Convert to String
let num = 100;
String(num); // "100"
📌 Convert to Number
let str = "50";
Number(str); // 50
📌 Convert to Boolean
Boolean(1); // true
Boolean(0); // false
🧪 Practice Programs
✅ 1. Calculator Program
let a = 10;
let b = 5;console.log("Add:", a + b);
console.log("Subtract:", a - b);
console.log("Multiply:", a * b);
console.log("Divide:", a / b);
👉 Advanced (User Input)
let num1 = Number(prompt("Enter first number:"));
let num2 = Number(prompt("Enter second number:"));alert("Sum = " + (num1 + num2));
✅ 2. Temperature Converter
Celsius to Fahrenheit
let c = 30;
let f = (c * 9/5) + 32;console.log("Fahrenheit:", f);
Fahrenheit to Celsius
let f = 86;
let c = (f - 32) * 5/9;console.log("Celsius:", c);






