
📎 This article includes 2 downloadable practice files ↓
📘 JavaScript Beginner Course · Lesson 2 of 8
In this article
- Types
- Indian formatting
- String methods
- Practice
Variables hold values. Modern JavaScript uses const (can’t be reassigned) and let (can); avoid the old var.
“`javascript
const customer = “Sharma Traders”;
let qty = 12;
const amount = qty * 60;
console.log(`${customer}: ${qty} x Rs 60 = Rs ${amount}`); // template literal
“`
Types
Numbers (one type for integers and decimals), strings, booleans (true/false), plus null, undefined, objects and arrays. typeof tells you which.
(1234567).toLocaleString("en-IN") gives 12,34,567.
String methods
“`javascript
” ravi kumar “.trim().toUpperCase(); // “RAVI KUMAR”
“INV-2026-0145”.split(“-“); // [“INV”, “2026”, “0145”]
“Sharma Traders”.includes(“Traders”); // true
“`
⚠️ “5” + 3 is “53” (text joining) but “5” * 3 is 15. Convert text to numbers with Number(“5”) before maths.
Practice
Run the script, then change the quantity and rate.
📎 Practice files for this article
Free to use for learning. Files with macros (.bas) are plain text — import them with Alt+F11 → File → Import File, and always test on a copy.
✨ Ask AI about this articleStuck on a step? Ask a question and the AI answers using this article.
Free · AI can be wrong