I have my website that shows the country list and when you click it you see the flag and sub region. If I wanted to add more information from the api how would I add it to the function? For example if I wanted to add the time zones and region. If I wanted to just keep adding them how would I write them into the code? jsfiddle
xhttp.open("GET", "https://restcountries.com/v2/all", true);
xhttp.send();
function clickMe(index) {
//search and remove all image tags already inserted
document.querySelectorAll('#list img').forEach(
function(item) {
item.remove();
});
//search and remove all div1 tags already inserted
document.querySelectorAll('#list div1').forEach(
function(item) {
item.remove();
});
//create flag image on website
li = document.getElementById(index);
img = document.createElement("img")
img.src = respJSON[index].flag;
li.append(img);
//create subregion text on website
let div = document.createElement("div1");
div.innerText = respJSON[index].subregion;
li.append(div);
} ```