Skip to content

Instantly share code, notes, and snippets.

@satoryu
Created June 6, 2019 06:10
Show Gist options
  • Save satoryu/238c580e36e9b709e61a9b114e776eca to your computer and use it in GitHub Desktop.
Save satoryu/238c580e36e9b709e61a9b114e776eca to your computer and use it in GitHub Desktop.
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