Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function problemSolved(input){
- let cnt = 0;
- let stringToCheck = input[0].toLowerCase();
- let pattern = input[1] !== undefined ? input[1].toLowerCase() : ' ';
- while(stringToCheck.indexOf(pattern)!=-1){
- cnt++;
- var index = stringToCheck.indexOf(pattern)+1;
- stringToCheck = stringToCheck.substring(index);
- }
- console.log(cnt);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement