Command Palette

Search for a command to run...

Hectal
Phase 12: Big Data: Canvas, Hit-Testing and Performance
Data Visualization · Exercise 3 of 4 PreviousNext
Advanced

Do the sum in a worker

The page adds the numbers 1 to 3,000,000 on the main thread, which freezes it for a moment.

Move the loop into a Web Worker built from text, and show Total: 4500001500000 when the worker answers.

What Check tests

  1. The page shows the total
  2. The loop runs in a worker
  3. The page code has no summing loop of its own

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.