Skip to content

Instantly share code, notes, and snippets.

@rafagarcia
Last active September 11, 2018 16:38
Show Gist options
  • Save rafagarcia/a2a2a82d7aab7cbc5448970ad3730e37 to your computer and use it in GitHub Desktop.
Save rafagarcia/a2a2a82d7aab7cbc5448970ad3730e37 to your computer and use it in GitHub Desktop.
JS Bin// source http://jsbin.com/kixipiqeka
const numbers = [10, 20, 30, 40];
let updatedNumbers = numbers
.map((num) => num * 2)
.filter((num) => num > 50);
let 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;
}, []);
console.log(updatedNumbers)
console.log(doubledOver50)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment