Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function findOccOfWordInSentence ([text,word]) {
- [text, word] = [text, word];
- text = text.toLowerCase ();
- let regex = new RegExp ('\\b' + word + '\\b', 'ig');
- let match = text.match (regex);
- if (match != null) {
- console.log (match.length);
- }
- }
- findOccOfWordInSentence (
- [
- "How do you plan on achieving that? How? How can you even think of that?",
- "how"
- ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement