Last active
July 12, 2018 04:01
-
-
Save maulberto3/f3d6a64137b742156df36707db8b9494 to your computer and use it in GitHub Desktop.
Reduce example #3
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 arr = [["dog", 1], ["cat", 2], ["bear", 3]]; | |
const func1 = ([key, v1]) => ({ [key]: v1 }); // creates an object out of the array | |
const obj2 = arr.map(func1) | |
console.log(JSON.stringify(obj2, null, 2)); // Prints [ { "dog": 1 }, { "cat": 2 }, { "bear": 3 } ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment