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
Double every number
easy10 minUse map to double each value and join the result with commas.
- 2
Pull out a property
easy10 minTurn an array of user objects into a comma-separated list of names.
- 3
Uppercase every word
easy10 minMap a list of words to uppercase and join them with spaces.
- 4
Number the list
easy10 minUse the index to build a numbered list separated by pipes.
- 5
Show map keeps the original
medium10 minMap a list to doubles and show the original still joined by commas.
Find the bug(5)
- 1
Fix the missing return
easy8 minA callback with braces must return a value.
- 2
Fix forEach used instead of map
easy8 minforEach gives nothing back, so there is no new array.
- 3
Fix the whole object returned
easy8 minOnly the name should come out, not the object itself.
- 4
Fix the result never used
easy8 minmap returns a new array; the original is left unchanged.
- 5
Fix the index used as the value
easy8 minThe 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