console.log(count("the quick brown fox jumps over the lazy dog", 'the')); //output 2
function count(str, find)
{
var temp = str.split(' ');
console.log(temp);
count = 0
for(var i = 0; i<temp.length ; i++)
{
if(temp[i] == find)
{
count++
}
}
return count;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: