Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
JAVASCRIPT FOUNDATIONS / CHAPTER 01 / Learn / LESSON 02
Second class. A budget has numbers you reuse — for example monthly income. Instead of writing 1500 everywhere, store it in a variable.
Modern JavaScript uses const (do not reassign) or let (may change later). Syntax: const income = 1500;
The name is a label. The value is the content. console.log(income) prints the number, not the word income.
Mini example:
const tip = 10; console.log(tip);
Common mistake: income = 1500 without const/let (fails in strict mode); or "1500" in quotes when you need a number.
A variable stores a number under a name. console.log prints the value.
JS CONSOLE IDLE
›