Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. function solve(arr) {
  2. let input = arr.slice();
  3.  
  4. output = [];
  5. input.shift()
  6.  
  7. for (i = 0; i < input.length; i += 1) {
  8. let obj = {},
  9. line = input[i].replace(/\|/gi,'').trim().split(' ');
  10.  
  11. obj['Town'] = line[0];
  12. obj['Latitude'] = Number(line[1]);
  13. obj['Longitude'] = Number(line[2]);
  14.  
  15. output.push(JSON.stringify(obj));
  16. }
  17. console.log(`[${output.join(',')}]`);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement