Array.fromintermediateArray.from([1, 2, 3], n => n * n)
// β [1, 4, 9]Pass a mapping function as the second argument to Array.from() to transform each element.
The second argument to Array.from() is a mapping function applied to each element as the array is built. This lets you combine creation and transformation in a single step.
Challenge: Implement createEvenNumbers that returns the first count positive even numbers: [2, 4, 6, β¦, count*2].
createEvenNumbers(5) // β [2, 4, 6, 8, 10]
createEvenNumbers(1) // β [2]