Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let pathLocations = /(=|\/)(?<loc>[A-Z][A-Za-z]{2,})\1/g
- let destinations = input.match(pathLocations);
- let location = [];
- let travelpoints = 0;
- if (destinations.test(input)) { // or destination !== null
- destinations.forEach(match =>{
- let town = match.slice(1,-1)
- location.push(town)
- travelpoints+=(town).length
- })
- }
- console.log(`Destinations: ${location.join(", ")}`);
- console.log(`Travel Points: ${travelpoints}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement