Skip to content

Instantly share code, notes, and snippets.

@macjabeth
Created May 23, 2019 05:07
Show Gist options
  • Save macjabeth/a591865ee2173f99028dc6698c1f9ffa to your computer and use it in GitHub Desktop.
Save macjabeth/a591865ee2173f99028dc6698c1f9ffa to your computer and use it in GitHub Desktop.
Examples written for my students.
function filter(arr, func) {
const res = [];
for (const val of arr) {
if (func(val)) {
res.push(val);
}
}
return res;
}
console.log(filter(
[2, 4, 6, 8, 10],
(currentValue) => {
return currentValue > 5;
}
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment