Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- countSubstringOccur(['in', 'We are living in a yellow submarine. We don\'t have anything else. Inside the submarine is very tight. So we are drinking all the day. We will move out of it in 5 days.'])
- countSubstringOccur(['your', 'No one heard a single word you said. They should have seen it in your eyes. What was going around your head.']);
- countSubstringOccur(['but', 'But you were living in another world tryin\' to get your message through.']);
- function countSubstringOccur(value) {
- var keyword = value[0].toLowerCase();
- var text = value[1].toLowerCase();
- var matched = new RegExp(keyword, "g");
- var counter = text.match(matched);
- return console.log(counter.length);
- }
Advertisement
Add Comment
Please, Sign In to add comment