Skip to content

Instantly share code, notes, and snippets.

@KrunchMuffin
Created November 17, 2021 00:16
Show Gist options
  • Save KrunchMuffin/991aa999e6d9c35c6d7c8142e01595a0 to your computer and use it in GitHub Desktop.
Save KrunchMuffin/991aa999e6d9c35c6d7c8142e01595a0 to your computer and use it in GitHub Desktop.
// The second argument/parameter is expected to be a (callback) function
const findWaldo = function(names, found) {
names.forEach(e => {
if (e === 'Waldo') found();
});
};
const actionWhenFound = function() {
console.log('Found him!');
};
findWaldo(['Alice', 'Bob', 'Waldo', 'Winston'], actionWhenFound);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment