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 sum = 0
- if (input.match(path)) {
- result = input.match(path).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