Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function travel(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 el of locations) {
- points += el.length
- }
- console.log(`Destinations: ${locations.join(', ')}`)
- console.log(`Travel Points: ${points}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment