Guest User

js

a guest
Oct 30th, 2016
108
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function main (lines) {
  2. let text = lines[0].toLowerCase();
  3. let word = lines[1].toLowerCase();
  4.  
  5. let index = text.indexOf(word);
  6. let counter = 0;
  7.  
  8. while (index != -1) {
  9. counter++;
  10. index = text.indexOf(word ,index + 1);
  11. }
  12.  
  13. console.log(counter);
  14. }
  15.  
  16. let lines = ['ababa caba', 'aba'];
  17. main(lines);
RAW Paste Data