Skip to content

Instantly share code, notes, and snippets.

@topherPedersen
Created May 24, 2020 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save topherPedersen/615d1b64750edefe9965fb484c0bd594 to your computer and use it in GitHub Desktop.
Save topherPedersen/615d1b64750edefe9965fb484c0bd594 to your computer and use it in GitHub Desktop.
Simple JavaScript .map() Method Example
let oldArray = ["foo", "bar", "baz"];
let newArray = oldArray.map( (item) => {
if (item === "baz") {
return "B@Z!";
} else {
return item;
}
});
console.log(newArray);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment