i want to match pattern on the string using for loop and i create code like this :
function partialCheck(str, partial) {
var pattern = [];
for (var i =0; i <= str.length; i++){
if(partial === str[i]+str[i+1]+str[i+2]){
pattern.push(partial);
}
}
return pattern;
}
on the test case, it should show the result like this :
console.log(partialCheck('abcdcabdabc', 'abc')); // ["abc","abc"]
console.log(partialCheck('accHghebchg', 'chg')); // ["cHg","chg"]
but on second case, it resulted like this :
console.log(partialCheck('accHghebchg', 'chg')); // ["chg"]
the question is it possible to put cHg to the array by ignoring case sensivity without using regex?
thanks before.
toLowerCase()on both sides of===.