Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function destinationMaper(input) {
- let path = /([=||\/])(?<name>[A-Z][A-Za-z]{2,})\1/g
- let result = []
- let match = input.match(path)
- let sum = 0
- if (match) {
- result = match.reduce((acc, x) => {
- let name = x.split(/[=|\/]/g).filter(x => x !== "")
- sum += (name[0]).length
- acc.push(name)
- return acc
- }, [])
- }
- console.log(`Destinations: ${result.join(', ')}\nTravel Points: ${sum}`)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement