I was wondering how I could output the different currency symbol which the user wants to covert the amount to in my currency converter? For example, if I wanted to convert £20 to euros in the final output of the new amount which was the euro value of £20 how can I get the euro symbol to be outputted? The final output is only numbers and I want a currency symbol in front of the final value amount output and I was wondering how I could do this for every currency for the output amount. I'm importing the live exchange rates from an API therefore, how can I import the exchange rates but add the currency symbol?
JAVASCRIPT
// Fetch exchange rate data from api
$.getJSON("https://api.fixer.io/latest?base=ZAR", function(data) {
var currencies = [];
$.each(data.rates, function(currency, rate) {
// Currency options dropdown menu
currencies.push("<option id='" + currency.toLowerCase() + "' value='" + rate + "' >" + currency + "</option>");
});
$(".currency-list").append(currencies);
})
//Calculate and output the new amount
function exchangeCurrency() {
var amount = $(".amount").val();
var rateFrom = $(".currency-list")[0].value;
var rateTo = $(".currency-list")[1].value;
if (amount == undefined || rateFrom == "--Select--" || rateTo == "--Select--") {
$(".results").html("0");
} else {
$(".results").html((amount * (rateTo * (1 / rateFrom))).toFixed(2));
}
}