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