Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function countStringOccurrences(text, word) {
- let words = text.split(' ');
- let wordCounter = 0;
- for (let el of words) {
- if (el === word) {
- wordCounter++
- }
- }
- console.log(wordCounter);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement