Skip to content

Instantly share code, notes, and snippets.

@elliotlarson
Last active July 22, 2018 05:36
Show Gist options
  • Select an option

  • Save elliotlarson/d00b3bbb960b4ba7a7830fa8db187248 to your computer and use it in GitHub Desktop.

Select an option

Save elliotlarson/d00b3bbb960b4ba7a7830fa8db187248 to your computer and use it in GitHub Desktop.
const newCharacters = characters.map(c => (c === oldName ? newName : c));
// or without the ternary
const newCharacters = characters.map(c => {
if (c === oldName) {
return newName;
}
  return c;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment