Created
January 18, 2019 06:46
-
-
Save newbornfrontender/b55c095b2c2ee9fc75a0762fedd14865 to your computer and use it in GitHub Desktop.
Destructuring. Multiple return values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const addres = ['37.6068', '55.7386']; | |
function getCoordinates(addres) { | |
const coordinates = { | |
lon: addres[0], | |
lat: addres[1], | |
}; | |
return [coordinates.lon, coordinates.lat]; | |
}; | |
const [longitude, latitude] = getCoordinates(addres); | |
console.log(`longitude: ${longitude}, latitude: ${latitude}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment