Guest User

03. Santa's Reindeer

a guest
Mar 23rd, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. function solveSantasReindeer(text) {
  2. let reindeerRegEx = /\*+[A-Z][a-z]+\*+/g
  3. let reindeers = text.match(reindeerRegEx)
  4. text = text.split(' ').filter(x => x !== '')
  5.  
  6. text.map(x => {
  7. reindeers.map(y => {
  8. if (x === y) {
  9. console.log(x, text.indexOf(x));
  10. text.splice(text.indexOf(x), 1)
  11. }
  12. })
  13. })
  14.  
  15. console.log(reindeers.join(', '))
  16. console.log('********************')
  17. console.log(text.join(' '))
  18. }
Add Comment
Please, Sign In to add comment