0

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`;
    }
};

1 Answers1

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

//call method Celsius(298) here like this

console.log(this.Celsius(298));

//or 

console.log(Celsius(298));
Shoma
  • 479
  • 3
  • 9