Fundamentalen

Untitled

Jul 21st, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 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.'])
  2. countSubstringOccur(['your', 'No one heard a single word you said. They should have seen it in your eyes. What was going around your head.']);
  3. countSubstringOccur(['but', 'But you were living in another world tryin\' to get your message through.']);
  4.  
  5. function countSubstringOccur(value) {
  6.     var keyword = value[0].toLowerCase();
  7.     var text = value[1].toLowerCase();
  8.     var matched = new RegExp(keyword, "g");
  9.     var counter = text.match(matched);
  10.  
  11.     return console.log(counter.length);
  12. }
Advertisement
Add Comment
Please, Sign In to add comment