Solved - TypeError: Cannot read properties of null (reading 'length')
//A function that counts the occurrence of an specific word from string using regex object
function wordCount(w,arr) {
let sum = 0
let re = new RegExp(w, 'ig')
for (let i = 0; i < arr.length; i++) {
//The match() retures null if the word is not in the string
//.lenght reture array lenght
//If word not fount add 0 Eles add the count
sum += (!arr[i].match(re))? 0 : arr[i].match(re).length
}
return sum
}