kristina111

Untitled

Oct 30th, 2016
126
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function problemSolved(input){
  2.     let cnt = 0;
  3.     let stringToCheck = input[0].toLowerCase();
  4.     let pattern = input[1] !== undefined ? input[1].toLowerCase() : ' ';
  5.     while(stringToCheck.indexOf(pattern)!=-1){
  6.         cnt++;
  7.         var index = stringToCheck.indexOf(pattern)+1;
  8.         stringToCheck = stringToCheck.substring(index);
  9.         }
  10.     console.log(cnt);
  11. }
RAW Paste Data