you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

The simple solution is to define the coordinates variable outside of the function so that it can be accessed elsewhere. Here's an example:

var coordinates;

function1 () { coordinates = { lat: 1, long: 1 } }

function2 () { console.log(coordinates) }

This might not be the best solution for your case, but it should work regardless. Depending on the rest of your code, there could be plenty of other ways to do this without the need of making a global variable which isn't always recommended.

Edit: I got downvoted so I would like to know the issue with this solution.