Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save r37r0m0d3l/1cfde70a9d5f93922160333cb198755a to your computer and use it in GitHub Desktop.

Select an option

Save r37r0m0d3l/1cfde70a9d5f93922160333cb198755a to your computer and use it in GitHub Desktop.
const numbers = [10, 20, 30, 40];
const doubledOver50 = numbers.reduce((finalList, num) => {
num = num * 2; //double each number (i.e. map)
//filter number > 50
if (num > 50) {
finalList.push(num);
}
return finalList;
}, []);
doubledOver50; // [60, 80]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment