Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function townsToJSON(input) {
- let result = [];
- for (let i = 1; i < input.length; i++) {
- let line = input[i];
- let row = line.split('|');
- row.pop();
- row.shift();
- row[0] = row[0].trim();
- row[1] = row[1].trim();
- row[2] = row[2].trim();
- let [town, latitude, longitude] = row;
- latitude = Number(latitude).toFixed(2);
- longitude = Number(longitude).toFixed(2);
- result.push({ Town: town, Latitude: Number(latitude), Longitude: Number(longitude) });
- }
- console.log(JSON.stringify(result));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement