Advertisement
kstoyanov

02. Towns js fundamentals

Jul 1st, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(args) {
  2.   const townObject = {};
  3.  
  4.   args.forEach((town) => {
  5.     const takeTown = town.split('|');
  6.  
  7.     const [townName, townLatitude, townLongitude] = takeTown;
  8.  
  9.     townObject.town = townName.trimEnd();
  10.     townObject.latitude = Number(townLatitude).toFixed(2);
  11.     townObject.longitude = Number(townLongitude).toFixed(2);
  12.  
  13.     console.log(townObject);
  14.   });
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement