Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function destination(input) {
- let pattern = /[=|\/]([A-Z][A-Za-z]){2,}\1/g;
- let locations = [];
- let points = 0;
- while ((match = pattern.exec(input)) != null) {
- let wordPattern = /\w+/g;
- let words = wordPattern.exec(match[0]);
- locations.push(words[0]);
- }
- for (let element of locations) {
- points += element.length;
- }
- console.log(`Destinations: ${locations.join(", ")}`);
- console.log(`Travel Points: ${points}`);
- }
- destination("=Hawai=/Cyprus/=Invalid/invalid==i5valid=/I5valid/=i=");
Advertisement
Add Comment
Please, Sign In to add comment