Skip to content

Instantly share code, notes, and snippets.

@jackpordi
Created September 11, 2019 21:32
Show Gist options
  • Save jackpordi/3ed5b77871e2a3ca87a3fde3c624621e to your computer and use it in GitHub Desktop.
Save jackpordi/3ed5b77871e2a3ca87a3fde3c624621e to your computer and use it in GitHub Desktop.
const myArray = [1, 4, 9, 16];
function timesTwo(x) {
return x * 2;
}
// Pass the function to a map
const mappedArray = myArray.map(timesTwo);
// Expected output: Array [2, 8, 18, 32]
console.log(mappedArray);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment