back

Naive String Search

function subStringSearch(str,word){
let count = 0
for(let i=0; i<str.length; i++){
for(let j=0;j < word.length;j++){
if(str[i+j] !== word[j]){
break;
}
// when j is last char of word , all char match
if (j === word.length -1) count++;
}
}
return count;
}
subStringSearch("wow omgz omg great","omg")