Arrays & Iteration
JavaScript Fundamentals • 14 pts
Arrays: Lists of Values
Arrays store multiple values in a single variable. They're like numbered lists where each item has an index starting from 0.
Array Methods
map() transforms each element, filter() keeps only matching elements, and reduce() combines all elements into a single value.
Output: —
- • Create function sum
- • sum([1,2,3]) should equal 6
- • Handle array of zeros
- • Handle negative numbers
What does [1,2,3].map(x => x * 2) return?
Select an answer