Variables and types
Store values safely with const and let, and understand what JavaScript considers a type.
What you will be able to do
- Declare variables with const and let
- Recognise primitive types
- Use template literals
JavaScript has dynamic types: a variable can hold any kind of value. Prefer const by default and use let only when you must reassign.
const learner = "Amina";
let streak = 4;
streak = streak + 1;
const greeting = `Welcome back, ${learner}. Streak: ${streak} days.`;
console.log(greeting);| Type | Example | Notes |
|---|---|---|
| string | "hello" | Text in quotes or backticks. |
| number | 42, 3.14 | One numeric type, including decimals. |
| boolean | true / false | Result of comparisons. |
| null | null | An intentional absence. |
| undefined | undefined | A missing value. |
| object | { name: "Amina" } | Collections and complex values. |
Your turn
EasyBuild a greeting
Create const name and let points, add 10 to points, then log a template literal with both values.
JAVASCRIPT · starter
const name = "Rafiq";
let points = 40;
// add 10 points and log a greetingCheck your understanding before moving on.
Knowledge checkQuestion 1
Which declaration allows reassignment?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.