JavaScript Dynamic Import — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Dynamic Import lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(5)
- 1
Load a module dynamically
easy10 minSimulate import() with a promise and use its export.
- 2
Await a dynamic import
easy10 minUse async and await to load a simulated module.
- 3
Load conditionally
easy10 minOnly load the module when it is actually needed.
- 4
Handle a failed import
easy10 minCatch a rejected dynamic import and report the message.
- 5
Destructure the resolved module
medium10 minPull two exports straight out of the resolved value.
Find the bug(5)
- 1
Fix the module used without waiting
easy8 minThe result is a promise until it resolves.
- 2
Fix await missing inside the async function
easy8 minWithout await, math is a promise, not the module.
- 3
Fix the module loaded even when not needed
easy8 minThe module should only load when the condition is actually true.
- 4
Fix the error message discarded
easy8 minThe catch block should report the real error, not a fixed message.
- 5
Fix the destructuring done too early
easy8 minThe module has not resolved yet when the names are pulled out.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace