I have written my first JavaScript program from scratch and am looking for advice to check whether it is efficient and effective or how it could be improved.
var apiURL = 'https://services.domain.com';
function dataPlanOutput(countryCode) {
document.getElementById("dataplan_list").innerHTML = "";
network_url = apiURL + '/api/v4/countries/' + countryCode ;
network_new_url = "http://cors.io/?" + network_url;
$.getJSON(network_new_url, function (networkGroup) {
$.each(networkGroup.list, function (i, list) {
var countryName = list.region;
var networkGroupId = list.networkGroupId;
function myDataPlan(networkGroupId, countryCode) {
data_url = apiURL + '/api/v4/networkGroups/' + networkGroupId + '/plansExt?countryCode=' + countryCode;
data_new_url = "http://cors.io/?" + data_url;
$.getJSON(data_new_url, function (dataPlan) {
$.each(dataPlan.list, function (i, list) {
//Price
content = '<tr>';
var currencyLetter = list.currency;
if (currencyLetter == 'USD') {
var curencySymbol = currencyLetter.replace("USD", "$");
}
else if (currencyLetter == 'GBP') {
var curencySymbol = currencyLetter.replace("GBP", "£");
}
else if (currencyLetter == 'JPY') {
var curencySymbol = currencyLetter.replace("JPY", "¥");
}
else if (currencyLetter == 'EUR') {
var curencySymbol = currencyLetter.replace("EUR", "€");
};
content += '<td>' + curencySymbol + list.price + '</td>';
//Data Limits
var dataLimit;
if (list.dataUnlimited) {
dataLimit = 'Unlimited';
}
else {
var dataLimitInKB = list.dataLimitInKB;
if ((dataLimitInKB / (1024.0 * 1024.0)) >= 1.0) {
var measure = " GB";
var data = dataLimitInKB / ((1024.0) * (1024.0));
}
else if (dataLimitInKB / 1024.0 >= 1.0) {
var measure = " MB";
var data = dataLimitInKB / 1024.0;
}
data = Math.round(data * 100) / 100;
dataLimit = data + measure;
}
content += '<td>' + dataLimit + '</td>';
//Data Length
content += '<td>' + list.validityPeriodInDays + ' Days</td>';
content += '</tr>';
$(content).appendTo("#dataplan_list");
});
});
}
myDataPlan(networkGroupId, countryCode);
document.getElementById('dataplan_list').innerHTML += '<tr><td>' + countryName + '<td></tr>';
});
});
}