Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(arr) {
- const inputArr = arr.slice(1);
- const towns = [];
- const regex = /\s*\|\s*/;
- inputArr.forEach((el) => {
- const arrTown = el.split(regex).filter(Boolean);
- const longi = Number(arrTown[2]).toFixed(2);
- const lati = Number(arrTown[1]).toFixed(2);
- const townObj = { Town: arrTown[0], Latitude: Number(lati), Longitude: Number(longi) };
- towns.push(townObj);
- });
- console.log(JSON.stringify(towns));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement