Replace item in a JavaScript array

Let's assume that we want to replace an item in an array in JavaScript. For example, we want to replace Erik with Erik Martín:

// Declaring array
let arr = ['Carlos', 'Erik', 'Luis', 'Victoria', 'Jorge', 'Erik'];

// Replace element using map
let replaced = => name === 'Erik' ? 'Erik Martín' : name);

// ['Carlos', 'Erik Martín', 'Luis', 'Victoria', 'Jorge', 'Erik Martín']

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.