function lookupRemote(searchTerm) { var defaultReturnValue = 1010; var returnValue = defaultReturnValue; $.getJSON(remote, function(data) { if (da
The function you pass to getJSON is run when the response to the HTTP request arrives which is not immediately.
getJSON
The return statement executes before the response, so the variable hasn't yet been set.
Have your callback function do what needs doing with the data. Don't try to return it.