how to change elements in array and return a new array code example Example: javascript replace array element array.splice(array.indexOf(valueToReplace), 1, newValue);