Skip to main content

JavaScript Array map — exercises and bug fixes

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

    Double every number

    easy10 min

    Use map to double each value and join the result with commas.

  2. 2

    Pull out a property

    easy10 min

    Turn an array of user objects into a comma-separated list of names.

  3. 3

    Uppercase every word

    easy10 min

    Map a list of words to uppercase and join them with spaces.

  4. 4

    Number the list

    easy10 min

    Use the index to build a numbered list separated by pipes.

  5. 5

    Show map keeps the original

    medium10 min

    Map a list to doubles and show the original still joined by commas.

Find the bug(5)

  1. 1

    Fix the missing return

    easy8 min

    A callback with braces must return a value.

  2. 2

    Fix forEach used instead of map

    easy8 min

    forEach gives nothing back, so there is no new array.

  3. 3

    Fix the whole object returned

    easy8 min

    Only the name should come out, not the object itself.

  4. 4

    Fix the result never used

    easy8 min

    map returns a new array; the original is left unchanged.

  5. 5

    Fix the index used as the value

    easy8 min

    The first argument is the value, not the position.

Ready to write the code?

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

Open the workspace