Skip to content

Instantly share code, notes, and snippets.

@saracope
Created July 25, 2017 15:23
Show Gist options
  • Save saracope/4097176f3c6ae87e6af29e3896e6b6d1 to your computer and use it in GitHub Desktop.
Save saracope/4097176f3c6ae87e6af29e3896e6b6d1 to your computer and use it in GitHub Desktop.
JavaScript map()
JavaScript map()
Use it when: You want to translate/map all elements in an array to another set of values.
Exercises for .map():
1.) Given an array of words, transform that to contain the length of each word.
2.) Given an array of dollar values, transform it to contain the values converted to another currency (your choice).
3.) Given and array of numbers 1-7, transform it to contain the corresponding day of the week. 1 is equal to Monday.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment