Remove decimals if not needed
This commit is contained in:
parent
b81d675e4c
commit
f16ac8010b
1 changed files with 5 additions and 1 deletions
|
@ -30,7 +30,11 @@ module.exports = {
|
||||||
break;
|
break;
|
||||||
case "F":
|
case "F":
|
||||||
if (args[2].toUpperCase() === "C") {
|
if (args[2].toUpperCase() === "C") {
|
||||||
const celsius = ((initial_temp - 32) * 5 / 9).toFixed(2);
|
let celsius = ((initial_temp - 32) * 5 / 9).toFixed(2);
|
||||||
|
if(celsius[celsius.length - 1] === '0' && celsius[celsius.length - 2] === "0"){
|
||||||
|
celsius = celsius.replace(".00","")
|
||||||
|
}
|
||||||
|
|
||||||
sendText = `${initial_temp}°F is ${celsius}°C`;
|
sendText = `${initial_temp}°F is ${celsius}°C`;
|
||||||
} else {
|
} else {
|
||||||
sendText = "Can only convert to fahrenheit from celsius";
|
sendText = "Can only convert to fahrenheit from celsius";
|
||||||
|
|
Loading…
Add table
Reference in a new issue