Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function destination(input) {
- let pattern =/([=||\/])(?<name>[A-Z][A-Za-z]{2,})\1/g
- let destArr = [];
- let travelPoints = 0;
- let match = input.match(pattern);
- if(match){
- for(let matches of match){
- let destination = matches.slice(1,-1);
- travelPoints += destination.length;
- destArr.push(destination);
- }
- }
- console.log(`Destinations: ${destArr.join(", ")}`)
- console.log(`Travel Points: ${travelPoints}`)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement