Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function destinationMapper(input) {
- let regex = /(=|\/)(?<place>[A-Z][a-zA-Z]{2,})\1/g;
- let matches;
- let places = [];
- let totalLength = 0;
- while ((matches = regex.exec(input)) !== null) {
- places.push(matches.groups.place);
- totalLength += matches.groups.place.length;
- }
- console.log(`Destinations: ${places.join(', ')}`);
- console.log(`Travel Points: ${totalLength}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement