Hello, heres my code to remove every other word and I am wondering if there is a simpler way to do this.
I created a separate function that removes every other word from an array. Then I called it on the ‘overusedWord’ array to go through each word and apply it to the betterWords array which from previous steps is just an array of strings without all of the unnecessary words.
const everyOtherRemover = (word, arr) => {
let counter = 0;
for(let i = 0; i<arr.length; i++){
if (word === arr[i]){
if(counter % 2 != 0){
counter++;
continue;
}
arr.splice(i, 1);
counter++;
}
}
};
overusedWords.map(word => {
everyOtherRemover(word, betterWords);
});