how to add and replace element in array object code example Example: javascript replace array element array.splice(array.indexOf(valueToReplace), 1, newValue);