Advertisement
bebo231312312321

Untitled

Mar 17th, 2023
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let pathLocations = /(=|\/)(?<loc>[A-Z][A-Za-z]{2,})\1/g
  3.     let destinations = input.match(pathLocations);
  4.     let location = [];
  5.     let travelpoints = 0;
  6.    
  7.    if (destinations.test(input)) { // or destination !== null
  8.     destinations.forEach(match =>{
  9.       let town = match.slice(1,-1)
  10.         location.push(town)
  11.         travelpoints+=(town).length  
  12.     })
  13.    }
  14.   console.log(`Destinations: ${location.join(", ")}`);
  15.   console.log(`Travel Points: ${travelpoints}`);
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement