I have a function that makes a $.getjson request and callbacks another function to use the results.
What Id like to do is call the functions twice and store the results in variable and use those 2 variables to do something. How would I go about this?
looks something like this
function getData(selection, callback){
$.getJSON(url, selection, function(data){
callback(data)
});
}
function doSomething(data){
return data + 2
}
then I want to store that data in a variable BUT call getData and callback twice and store results in different variables to do something with. Like:
a = getData("selection1", doSomething)
b = getData("selection2", doSomething)
console.log(a+b)