Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function hardWords(data) {
- let text = data[0];
- let wordsList = data[1];
- let newText = '';
- while (true) {
- let pattern = /[_]+/;
- let result = text.match(pattern);
- if (result === null) {
- break;
- }
- for (const word of wordsList) {
- if (word.length === result[0].length) {
- newText = text.replace(result, word);
- text = newText;
- }
- }
- }
- console.log(newText)
- }
Add Comment
Please, Sign In to add comment