Skip to main content

JavaScript import — exercises and bug fixes

5 hands-on exercises and 5 find-the-bug challenges for the JavaScript 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. 1

    Import a named value

    easy10 min

    Destructure a named export from a simulated module.

  2. 2

    Import and rename

    easy10 min

    Destructure a value under a different local name.

  3. 3

    Import a default export

    easy10 min

    Read a default export under a local name of your choice.

  4. 4

    Import everything as a namespace

    easy10 min

    Import a whole module as one object and use two of its exports.

  5. 5

    Import default and named together

    medium10 min

    Read both the default and a named export from one module.

Find the bug(5)

  1. 1

    Fix the wrong name imported

    easy8 min

    The destructured name does not match what the module exported.

  2. 2

    Fix the default imported with braces

    easy8 min

    A default export is imported without curly braces.

  3. 3

    Fix the rename applied to the wrong side

    easy8 min

    The local variable should be renamed, not the source property.

  4. 4

    Fix only one export imported

    easy8 min

    Destructuring one name means the others are never brought into scope.

  5. 5

    Fix the default and named mixed up

    easy8 min

    The default export and the named export were read from swapped keys.

Ready to write the code?

The editor, the automatic checks and the worked solutions open up with an account.

Open the workspace