Skip to content
Clairos Learn

JavaScript basics · Lesson 4 of 12 · 10 minutes

JavaScript basics: Number calculations

Arithmetic operates on numbers. Converting units explicitly keeps an otherwise correct expression from answering the wrong question.

Mastery 0/3Run itExplain itApply it
Web workshopInert preview · code inspection

Current edit

PreviewNo external resources

Understand the pattern

Arithmetic operates on numbers. Converting units explicitly keeps an otherwise correct expression from answering the wrong question.

Arithmetic operates on numbers. Converting units explicitly keeps an otherwise correct expression from answering the wrong question.

Misconceptions to reject

  • A string containing code executes automatically when it is assigned.
  • A successful element lookup guarantees that the rest of an event handler is correct.

This is a code-inspection lab, not a full JavaScript runtime.

Worked example and expected result
const seconds = 2;
const milliseconds = seconds * 1000;
const perRequest = milliseconds / 4;

Arithmetic operates on numbers. Converting units explicitly keeps an otherwise correct expression from answering the wrong question.

Try a variation

Adapt the final example to a different project name while retaining its structure and relationships. A different context still needs a real browser and accessibility check.

Explain it

Which statement correctly explains number calculations?

Apply it elsewhere

You reuse number calculations in a different project. What must still be verified?

Keep the momentum.

Complete the lab, then explain and apply the pattern.

Next: JavaScript basics: Boolean decisionsTry an incident drill

Anonymous lesson and mastery progress lasts for this session. Sign in to keep synced lesson XP between sessions; mastery stays device-local. No speed bonus, lost lives, or hint penalties.

Keep learning

  1. 01JavaScript basics: Readable stringsStrings represent text; quotes delimit the value, while concatenation combines text without changing its meaning.Practice
  2. 02JavaScript basics: Boolean decisionsComparisons produce booleans. Strict equality avoids implicit conversion when checking a known type.Practice
  3. 03JavaScript basics: Conditional branchesAn if statement chooses a path from a condition; the else branch handles the other case.Practice