Advertisement
bebo231312312321

Untitled

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