Advertisement
ErolKZ

Untitled

Dec 15th, 2021
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. function solve(input) {
  2.  
  3. let towns = input.map(el => el.split(' | '));
  4.  
  5. towns = towns.map(el => el.map(el2 => !isNaN(el2) ? el2 = Number(el2) : el2));
  6.  
  7. // console.log(towns);
  8.  
  9. let arr = [];
  10.  
  11. let obj = {};
  12.  
  13.  
  14. for (let el of towns) {
  15.  
  16. obj.town = el[0];
  17.  
  18. obj.latitude = el[1].toFixed(2);
  19.  
  20. obj.longitude = el[2].toFixed(2);
  21.  
  22. arr.push(obj);
  23.  
  24. obj = {};
  25.  
  26. }
  27.  
  28.  
  29. for (let el of arr) {
  30.  
  31. console.log(el);
  32.  
  33. }
  34.  
  35.  
  36.  
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement