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;
|
||||
if(weather.success){
|
||||
let tempInCelsius = weather.weather.match(tempRegex)[0];
|
||||
let tempInFahrenheit = `(${Math.round(tempInCelsius * 1.8 + 32)}°F)`;
|
||||
let splitWeather = weather.weather.split("°C");
|
||||
weather.weather = `${splitWeather[0]}°C ${tempInFahrenheit} ${splitWeather[1]}`
|
||||
let tempInFahrenheit = Math.round(tempInCelsius * 1.8 + 32);
|
||||
weather.weather = weather.weather.replace("°C", `°C ${tempInFahrenheit}°F`)
|
||||
}
|
||||
message.channel.send(weather.weather);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue