JavaScript Foundations·Language basics

Variables and types

Store values safely with const and let, and understand what JavaScript considers a type.

Beginner 10 min read Lesson 1 of 480 Challenge included
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.

basics.jsJavaScript
const learner = "Amina";
let streak = 4;

streak = streak + 1;

const greeting = `Welcome back, ${learner}. Streak: ${streak} days.`;
console.log(greeting);
TypeExampleNotes
string"hello"Text in quotes or backticks.
number42, 3.14One numeric type, including decimals.
booleantrue / falseResult of comparisons.
nullnullAn intentional absence.
undefinedundefinedA missing value.
object{ name: "Amina" }Collections and complex values.
Your turn

Build a greeting

Easy

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 greeting
Check 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 in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Next: Functions and scope
Lesson 1 of 480 · 0% of course