Advertisement
Todorov_Stanimir

01. Arriving in Kathmandu Final Exam 14 April 2019

Jul 26th, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function arrivingInKathmandu(input) {
  2.     while ((line = input.shift()) !== 'Last note') {
  3.  
  4.         let [rawName, length, geohash] = line.split(/[\=\<<]/).filter(x => x !== '');
  5.         rawName = rawName.split(/[\!\@\#\$\?]/).join('');
  6.         let name = rawName.match(/[A-Za-z0-9]+/gi).join('');
  7.  
  8.         if (name !== undefined && length !== undefined && geohash !== undefined && name === rawName
  9.             && Number(length) === geohash.length && Number(length) !== undefined) {
  10.             console.log(`Coordinates found! ${name} -> ${geohash}`);
  11.         } else {
  12.             console.log('Nothing found!');
  13.         }
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement