function countOccurences(s, word) {
const arr = s.split(" ");
let count = 0;
for (let i = 0; i < arr.length; i++) {
if (word == arr[i])
count++;
}
return count;
}
const s = "nodejs c python php c++ nodejs php php c# nodejs";
const word = "nodejs";
console.log(countOccurences(s, word));
/*
run:
3
*/