I want to have it so that when the variable is undefined the text displays "variable is undefined" but my current code does not do this.
if (metar.clouds) {
document.getElementById('cloud_block').classList.remove("d-none");
metar.clouds.forEach(cloud => {
var el = document.createElement('li');
el.innerHTML = cloud.text + ' at ' + cloud.feet + 'ft AGL. ';
document.getElementById("cloud_list").appendChild(el);
});
}
if (typeof cloud.feet === "undefined") {
cloud.feet = "variable is undefined";
}
Aucun commentaire:
Enregistrer un commentaire