I am receiving and displaying a numeric value from a external source (API). Now I need the color of the text change between RED and GREEN, depending on the value.
≥50 = red & <50 = green
Do you guys have any idea?
Chris
const api = "https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=county%20%3D%20%27SK%20stuttgart%27&outFields=cases,deaths,county,last_update,cases7_per_100k,recovered&returnGeometry=false&outSR=4326&f=json";
fetch(api).then((response) => {
return response.json();
}).then((json) => {
const cases = json.features[0].attributes.cases;
const deaths = json.features[0].attributes.deaths;
const cases7Per100k = json.features[0].attributes.cases7_per_100k;
const recovered = json.features[0].attributes.recovered;
const lastUpdate = json.features[0].attributes.last_update;
console.log(cases7Per100k)
document.getElementById("cases7Per100k").innerHTML = Math.round(cases7Per100k * 10) / 10 || 0;
});
<p id="cases7Per100k"></p>