Use replace instead of splitting for fahrenheit
Didn't know replace was a thing, so I did it in a kinda of shitty way before. Shouldn't be much difference except for the code being more understandable.
This commit is contained in:
parent
d8649ff943
commit
ecc162549e
1 changed files with 2 additions and 3 deletions
|
@ -20,9 +20,8 @@ module.exports = {
|
||||||
let tempRegex = /(-?\d+)(?=°C)/g;
|
let tempRegex = /(-?\d+)(?=°C)/g;
|
||||||
if(weather.success){
|
if(weather.success){
|
||||||
let tempInCelsius = weather.weather.match(tempRegex)[0];
|
let tempInCelsius = weather.weather.match(tempRegex)[0];
|
||||||
let tempInFahrenheit = `(${Math.round(tempInCelsius * 1.8 + 32)}°F)`;
|
let tempInFahrenheit = Math.round(tempInCelsius * 1.8 + 32);
|
||||||
let splitWeather = weather.weather.split("°C");
|
weather.weather = weather.weather.replace("°C", `°C ${tempInFahrenheit}°F`)
|
||||||
weather.weather = `${splitWeather[0]}°C ${tempInFahrenheit} ${splitWeather[1]}`
|
|
||||||
}
|
}
|
||||||
message.channel.send(weather.weather);
|
message.channel.send(weather.weather);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue