Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

map function

# map function
city_lengths = map(len, ['sanjose', 'cupertino', 'sunnyvale', 'fremont'])
print(list(city_lengths))

# [7, 9, 9, 7]
# Map takes a function and a collection of items. It makes a new, empty collection, runs the function on each item in the original collection and inserts each return value into the new collection. It returns the new collection.
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #map #function
ADD COMMENT
Topic
Name
3+7 =