Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let text = input.shift().split(" ");
- let arrayWithWords = input.shift();
- for (let i = 0; i < text.length; i++) {
- if (text[i].includes("_")) {
- let asterix = "";
- if (text[i].lastIndexOf("_") == text[i].length - 1) {
- asterix = "_".repeat(text[i].length);
- } else {
- asterix = "_".repeat(text[i].length - 1);
- }
- for (let j = 0; j < arrayWithWords.length; j++) {
- if (asterix.length == arrayWithWords[j].length) {
- text[i] = arrayWithWords[j];
- break;
- }
- }
- }
- }
- console.log(text.join(" "));
- }
Advertisement
Add Comment
Please, Sign In to add comment