Advertisement
bebo231312312321

Untitled

Apr 1st, 2023
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function destination(input) {
  2.     let pattern =/([=||\/])(?<name>[A-Z][A-Za-z]{2,})\1/g
  3.     let destArr = [];
  4.     let travelPoints = 0;
  5.     let match = input.match(pattern);
  6.  if(match){
  7. for(let matches of match){
  8.         let destination = matches.slice(1,-1);
  9.         travelPoints += destination.length;
  10.         destArr.push(destination);
  11.  
  12.     }
  13. }
  14.         console.log(`Destinations: ${destArr.join(", ")}`)
  15.         console.log(`Travel Points: ${travelPoints}`)
  16.  
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement