Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solveSantasReindeer(text) {
- let reindeerRegEx = /\*+[A-Z][a-z]+\*+/g
- let reindeers = text.match(reindeerRegEx)
- text = text.split(' ').filter(x => x !== '')
- text.map(x => {
- reindeers.map(y => {
- if (x === y) {
- console.log(x, text.indexOf(x));
- text.splice(text.indexOf(x), 1)
- }
- })
- })
- console.log(reindeers.join(', '))
- console.log('********************')
- console.log(text.join(' '))
- }
Add Comment
Please, Sign In to add comment