Advertisement
Onesible

Untitled

Feb 27th, 2025
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(template, text) {
  2.     let words = template.split(', ')
  3.  
  4.     for (let word of words) {
  5.         text = text.replace('*'.repeat(word.length), word)
  6.     }
  7.  
  8.     console.log(text)
  9. }
  10.  
  11. // function solve(template, string) {
  12. //     let arr = string.split(' ');
  13.  
  14. //     for (let word of arr) {
  15. //         if (word.startsWith('*')) {
  16. //             for (let temp of template.split(', ')) {
  17. //                 if (word.length == temp.length) {
  18. //                     arr.splice(arr.indexOf(word), 1, temp)
  19. //                 }
  20. //             }
  21. //         }
  22. //     }
  23. //     console.log(arr.join(' '))
  24. // }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement