Im new to software development and have been taking a class, im having an issue with finding out how to remove items in an array based on a 2nd argument character
Write a function "removeWordsWithChar" that takes 2 arguments:
- an array of strings
- a string of length 1 (ie: a single character) It should return a new array that has all of the items in the first argument except those that contain a character in the second argument (case-insensitive).
Examples:
----removeWordsWithChar(['aaa', 'bbb', 'ccc'], 'b') --> ['aaa', 'ccc']
----removeWordsWithChar(['pizza', 'beer', 'cheese'], 'E') --> ['pizza']
function removeWordsWithChar(arrString, stringLength) {
const arr2 = [];
for (let i = 0; i < arrString.length; i++) {
const thisWord = arrString[i];
if (thisWord.indexOf(stringLength) === -1) {
arr2.push(thisWord);
}
}
return arr2;
}