Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input){
  2.  
  3.     for(let i = 0; i < input.length; i++){
  4.         let [name, latitude, longitude] = input[i].split(' | ');
  5.  
  6.         let town = {
  7.             town: name,
  8.             latitude: Number(latitude).toFixed(2),
  9.             longitude: Number(longitude).toFixed(2)
  10.         };
  11.        
  12.         console.log(JSON.stringify(town));
  13.     }
  14. }
  15.  
  16. solve(['Sofia | 42.696552 | 23.32601', 'Beijing | 39.913818 | 116.363625']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement