Command Palette

Search for a command to run...

Hectal
Phase 12: Modules and Tooling
JavaScript · Exercise 4 of 6 PreviousNext
Intermediate

Load the report only when asked

REPORT_URL is a module whose default export makeReport(sales) returns a sentence. It prints report module loaded when it runs.

When Show report is clicked, load the module with dynamic import() and put makeReport(sales) into #report. The module must not load before the first click, and must load only once however many times the button is clicked.

What Check tests

  1. The module isn't loaded before the click
  2. After a click, the report says Total sales: 600
  3. A second click doesn't load the module again
  4. Uses dynamic import()
  5. No errors in the console

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.