Command Palette

Search for a command to run...

Hectal
Phase 1: Values, Types and Variables
JavaScript · Exercise 3 of 5 PreviousNext
Beginner

Fix the cart total

A café's cart adds a coffee (1.10) and a muffin (2.20). The page shows 3.3000000000000003 and the check total === 3.3 logs false.

Fix it by working in whole cents: add the prices as integers, then divide by 100 for the total. The page must show 3.3 (or 3.30) and the console must log true.

What Check tests

  1. The page shows 3.3
  2. The console logs true for the comparison
  3. The code works in whole cents (110 and 220)

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.