LESSON 07 OF 50

Check a value type

Use typeof to observe a variable type.

Official sourceECMAScript — typeof operatorReviewed: 2026-08-26
STEP 1 · LEARN

How it works

The typeof operator returns a string describing the operand type. For an ordinary numeric value, the result is “number”.

Correct example
const lessons = 10;
console.log(typeof lessons);

typeof inspects the numeric value without changing it.

Common mistake
const lessons = 10;
console.log('number');

The text only matches by accident; the exercise requires the operator that determines the type.

STEP 2 · APPLY

Your exercise

Declare lessons with 10 and print the result of typeof lessons.

STEP 3 · RUN

Write and run the code

script.jsJAVASCRIPT
Isolated consoleisolated
Preparing the runtime…
Run the code to see the result.
The draft stays only in this browser.Isolated QuickJS · no DOM, session or network
STEP 4 · CHECK

What needs to pass

0%not checked
  • lessons is declared with const.
  • The source uses typeof with lessons.
  • The output is number.
Explain the solution logic

The output is produced by typeof applied to the declared value, not by hard-coded text.