Write a JS function that finds, how many times a given word, is used in a given sentence. Note that letter case does not matter – it is case-insensitive.
The input comes as 2 string arguments:
-
The first one will be the sentence
-
The second one – the word.
Examples:
Input:
The waterfall was so high, that the child couldn’t see its peak.
the
Output:
2
Input:
How do you plan on achieving that? How? How can you even think of that?
how
Output:
3
Input:
There was one. Therefore I bought it. I wouldn’t buy it otherwise.
there
Output:
1
The output is a single number indicating the amount of times the sentence contains the word.