array.splice
JavaScript
strToArray.splice(elementToDelete, 1, after);
console.log(strToArray); //Outputs the new array with words replaced
strToArray.splice(elementToDelete, 1, after);
console.log(strToArray); //Outputs the new array with words replaced