i am trying to move my code from many if statements like this one...
if (localStorage.getItem("gbpUSD") === null) {   
    $http({
        method: 'GET',
        url: "http://devel.farebookings.com/api/curconversor/GBP/USD/1/"
    }).
    success(function(status) {
    // your code when success
    localStorage.gbpUSD = status.substring(4);
    });   
}
To a function like this one...
// Get exchange rate from API - a=from, b=to
function getEXRate(a, b) {
    // Access API
    $http({
        method: 'GET',
        url: "http://devel.farebookings.com/api/curconversor/"+ a +"/"+ b +"/1/"
    }).
    // Check if successful
    success(function(status) {
    // Return ammount only
    return status.substring(4);
    });
}
and then just call the function each time...
// Check if null, if so get exchange rate
if (localStorage.getItem("gbpUSD") === null) { 
    // Access API to get exchange rate
    localStorage.gbpUSD = getEXRate('GBP', 'USD');
}
the if statement works and give me a number like 1.543, however the function is returning undefined
Any ideas why???
Thanks
