mardi 14 avril 2020

conditional statement if value is greater or less then show error

I am trying to display a warning message if the temperature is higher then 40 or above - 10 but is not working.

I read some websites and in StackOverflow I found this Switch statement for greater-than/less-than to try to solve the problem but I still couldn't find a solution for what might be happening.

Can you help me out?

Many thanks.

function Celsius(kelvin) {
    let celsiusTemp = Math.round(kelvin - 273.15);
    if (celsiusTemp > 35) {
        console.log('too hot, use sunscreen ')
    } else
    if (celsiusTemp < 5) {
        console.log('too cold, get warm ')
    } else {
        return celsiusTemp + `°C`;
    }
};

Aucun commentaire:

Enregistrer un commentaire