Advertisement
bebo231312312321

Untitled

Mar 26th, 2023
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function townsToJSON (input){
  2. let result = []
  3. input.shift()
  4. input.forEach(x=>{  
  5.     let[_,town, latitude, longitude] = x.split(/\s*\|\s*/g).map(y=> isNaN(y)? y:Number(y).toFixed(2))
  6.     obj={Town: town,Latitude:+latitude,Longitude: +longitude,}
  7. result.push(obj)
  8. })
  9. console.log(JSON.stringify(result))
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement