Advertisement
Lulunga

Text Processing 08. Hard Word

Jul 19th, 2019
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let letter = input[0].split(' ');
  3.     let holes = input[1];
  4.     for (let hole of holes) {
  5.         let length = hole.length;
  6.         let searchHole = '_'.repeat(length);
  7.         for (let i = 0; i < letter.length; i++) {
  8.             if (letter[i] === searchHole || letter[i] === searchHole + ',' || letter[i] === searchHole + '.') {
  9.                 letter[i] = hole;
  10.             }
  11.  
  12.         }
  13.     }
  14.     console.log(letter.join(' '));
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement