Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function towns(array = []) {
- class Town {
- constructor(name, latitude, longitude) {
- this.name = name;
- this.latitude = latitude;
- this.longitude = longitude;
- }
- }
- for (let i = 0; i < array.length; i++) {
- let arr = array[i].split(" | ");
- let name = arr[0];
- let latitude = +arr[1];
- let longitude = +arr[2];
- town = new Town(name, latitude, longitude);
- console.log(
- `{ town: '${town.name}', latitude: '${latitude.toFixed(
- 2
- )}', longitude: '${longitude.toFixed(2)}' }`
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement