I need to check each element of an array for a certain letter. if the element contains this letter it should stay within the array, if it does not it should be removed.
currently I'm able to remove elements if they are exact, but not sure how to go about checking each index of each element.
var exampleList = ['alpha', 'beta','dog']
exampleList.filter(function(word) {
return (word == 'dog');
})
my end goal would be something like this.
letterToInclude = 'a'
var exampleList = ['alpha', 'beta','dog', 'mouse']
exampleList.filter(function(word) {
return (word == letterToInclude);
})
// returned values = ['alpha', 'beta']