Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function hardWord(letter) {
- let pattern = /[_]{1,}/g;
- let string = letter[0]
- let output = letter[0];
- while ((word = pattern.exec(string)) !== null) {
- letter[1].forEach(element => {
- if (element.length === word[0].length) {
- output = output.substr(0, word.index) + element + output.substr(word.index + element.length);
- }
- });
- }
- console.log(output);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement