1. Talking to the console
A program is a list of instructions that the computer follows from top to bottom. console.log(...) prints a message in the console, so you can see what your code is doing.
A variable is a labelled box that stores a value. Make one with let:
let city = "Pune"; puts the text Pune in a box called cityconsole.log(city); prints Pune
Text always goes inside quotes. Join pieces of text with +.
let city = "Pune";
console.log("Namaste from " + city);
Challenge: Say namaste
Create a variable name with your name, then print Namaste, followed by the name, e.g. Namaste, Asha.
2. let or const?
Use let for a value that will change, and const for a value that stays the same.
const shop = "Sharma Tea Stall"; — the shop name never changeslet cups = 12; and later cups = cups + 5; — the count of cups changes
Notice: when you change a let variable you write its name without let again. If you try to change a const, JavaScript stops with an error.
Good habit: start with const, and switch to let only when the value must change.
const shop = "Sharma Tea Stall";
let cups = 12;
cups = cups + 5;
console.log(shop, "sold", cups, "cups");
Challenge: The chai stall
Make a const called shopName with your stall’s name. Make a let called cups that starts at 12. Then 5 more cups are sold: add 5 to cups. Finally print cups (it should show 17).