Created
September 9, 2019 14:02
-
-
Save ozluy/51017a252c70f1c79da2cb6537c4cfd3 to your computer and use it in GitHub Desktop.
Reducer JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myArr = [{numbers:[1, 2, 3]}, {numbers:[4, 5, 6]}, {numbers:[7, 8, 9]}]; | |
/** Reducer array of objects to array of numbers */ | |
const myNewArr = myArr.reduce( | |
(acc, curr) => [...acc, ...curr.numbers], | |
[] //initialState | |
) | |
console.log(myNewArr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment