I have the following code. I think either the return statement or the assignment isn't working. The output on the alert is NaN.
let currencyRate = getCurrencyRate();
let output = currencyRate * 22.50;
alert(output);
function getCurrencyRate() {
let currencyRate = "";
$.ajax({
url: "http://free.currencyconverterapi.com/api/v5/convert?q=USD_INR&compact=y",
dataType: "json",
success: function(json) {
currencyRate += json.USD_INR.val;
return currencyRate;
}
})
}