Advertisement
bebo231312312321

Untitled

Mar 31st, 2023
85
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 sum = 0
  5.     if (input.match(path)) {
  6.         result = input.match(path).reduce((acc, x) => {
  7.             let name = x.split(/[=|\/]/g).filter(x => x !== "")
  8.             sum += (name[0]).length
  9.             acc.push(name)
  10.             return acc
  11.         }, []);
  12.     };
  13.     console.log(`Destinations: ${result.join(', ')}\nTravel Points: ${sum}`)
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement