Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
JAVASCRIPT DATA / CHAPTER 02 / Learn / LESSON 09
Eighth class. .map builds a new array by applying a function to each item.
function amountsOnly(items) { return items.map((item) => item.amount); }
Input [{amount:5},{amount:8}] → [5, 8]. The original array stays — you get a new one.
Common mistake: using for + push when the lesson wants map; or returning item instead of item.amount.
map builds a new array with the same length.
DATA STANDBY
›