// Replace 1 array element at index with item
arr.splice(index,1,item);
function solution(inputArray, elemToReplace, substitutionElem) {
return inputArray.map((x) => (x === elemToReplace ? substitutionElem : x));
}
array.splice(array.indexOf(valueToReplace), 1, newValue);
function solution(inputArray, elemToReplace, substitutionElem) {
return inputArray.map((item) => {
if (item === elemToReplace) {
return substitutionElem;
}
return item;
});
}
String.prototype.replaceArray = function(find, replace) {
var replaceString = this;
for (var i = 0; i < find.length; i++) {
replaceString = replaceString.replace(find[i], replace[i]);
}
return replaceString;
};