This is what filter is for. You can use it to create a new array based on a boolean condition. In this case, that condition is whether or not any given word in the array matches the given deletion-word.
Based on your usage of the slice function, I'm not sure if you're asking to user for an index to be removed or a word to be removed.
If you're asking for them to input a word they don't want, then you can do that quite easily:
const arr = ['lorem', 'ipsum', 'dolor', 'si', 'amet'];
const dWord = 'ipsum' // prompt("What word do you want to delete?");
const result = arr.filter(word => word != dWord);
console.log(result);
If you're asking them for an index that they want removed, then you can use the optional second argument of the function that filter takes, as follows:
const arr = ['lorem', 'ipsum', 'dolor', 'si', 'amet'];
const dIndex = 2 // prompt("What word do you want to delete?");
const result = arr.filter((word, index) => index != dIndex);
console.log(result);
The problem with your original code is how you are using the forEach function. When you run
['a', 'b', 'c'].forEach(function(find) {
// ...
});
You run a loop in which each iteration has 'a', 'b', or 'c' as find. In your case, your loop would run four times, with 1, 2, 3, and finally 4 as find. This isn't a problem until you then go back and index the original array with those numbers. The only reason it slightly worked is that your array was full of numbers. If it had been letters, you would have gotten an error. Then, tacking on the problems, the slice function expects to receive two indecies at which to make its cuts. You actually passed in the numbers from the array. So, on the first loop, your find is 1, which means that arr[find] is 2, so when you make the cut you're actually cutting at a completely unrelated index... it's a bit of a snowball of issues.