Advertisement
Kamend1

02.Towns

Mar 12th, 2025
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function towns (townArr) {
  2.     for (let town of townArr) {
  3.         let [name, latitude, longitude] = town.split(' | ');
  4.         let currentObj = {};
  5.         currentObj.town = name;
  6.         currentObj.latitude = Number(latitude).toFixed(2);
  7.         currentObj.longitude = Number(longitude).toFixed(2);
  8.  
  9.         console.log(currentObj);
  10.     }
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement