Created
June 6, 2019 06:10
-
-
Save satoryu/238c580e36e9b709e61a9b114e776eca to your computer and use it in GitHub Desktop.
This file contains 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 exampleValues = [2, 15, 8, 23, 1, 32]; | |
const result = exampleValues.reduce(({truthyValues, falseyValues}, exampleValue) => { | |
if (exampleValue > 10) { | |
truthyValues.push(exampleValue); | |
return { truthyValues, falseyValues }; | |
} | |
falseyValues.push(exampleValue); | |
return { truthyValues, falseyValues }; | |
}, { truthyValues: [], falseyValues: [] }); | |
console.log(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment