After writing this function, I noticed it only worked with a single string value.
contains(input, words) {
let input1 = input.split(' ');
for (var i = 0; i < input1.length; i++) {
if (input1[i] === words) {
return true;
} else {
return false;
}
}
}
let contains = Str.prototype.contains('hello me want coffee','hello');
This will return true.
I am now wondering how to modify the function so that it can work with multiple words.
let contains = Str.prototype.contains('hello me want coffe',['hello','want']);