const
declarations for variables that are never reassigned JS-0242382 let wind = jd.wind.speed + " " + windUnits;
383 let { username: author } = message.author;
384 let { icon, description: cloudness } = jd.weather[0];
385 let { id, name: displayCity, dt: timestamp } = jd;386 let { country } = jd.sys;
387 country += cFlags.get(country).emoji ? " " + cFlags.get(country).emoji : "";
388 message.reply(embed.currWeather(currentTemp, maxTemp, minTemp, pressure, humidity, wind, cloudness, icon, author, displayCity, country, units, id, timestamp));
382 let wind = jd.wind.speed + " " + windUnits;
383 let { username: author } = message.author;
384 let { icon, description: cloudness } = jd.weather[0];
385 let { id, name: displayCity, dt: timestamp } = jd;386 let { country } = jd.sys;
387 country += cFlags.get(country).emoji ? " " + cFlags.get(country).emoji : "";
388 message.reply(embed.currWeather(currentTemp, maxTemp, minTemp, pressure, humidity, wind, cloudness, icon, author, displayCity, country, units, id, timestamp));
382 let wind = jd.wind.speed + " " + windUnits;
383 let { username: author } = message.author;
384 let { icon, description: cloudness } = jd.weather[0];
385 let { id, name: displayCity, dt: timestamp } = jd;386 let { country } = jd.sys;
387 country += cFlags.get(country).emoji ? " " + cFlags.get(country).emoji : "";
388 message.reply(embed.currWeather(currentTemp, maxTemp, minTemp, pressure, humidity, wind, cloudness, icon, author, displayCity, country, units, id, timestamp));
375 message.reply(embed.error("There was an error getting the weather.", `${jd.cod || apiData.status}: ${jd.message || apiData.statusText}`));
376 return;
377 }
378 let { temp, temp_max, temp_min, humidity, pressure } = jd.main;379 let currentTemp = Math.round(temp);
380 let maxTemp = Math.round(temp_max);
381 let minTemp = Math.round(temp_min);
375 message.reply(embed.error("There was an error getting the weather.", `${jd.cod || apiData.status}: ${jd.message || apiData.statusText}`));
376 return;
377 }
378 let { temp, temp_max, temp_min, humidity, pressure } = jd.main;379 let currentTemp = Math.round(temp);
380 let maxTemp = Math.round(temp_max);
381 let minTemp = Math.round(temp_min);
Variables that are never re-assigned a new value after their initial declaration should be declared with the const
keyword.
This prevents the programmer from erroneously re-assigning to a read-only variable, and informs those reading the code that a variable is a constant value.
let pi = Math.PI
for (let x of xs) {
use(x);
}
let { a, b } = object;
use(a, b);
const pi = Math.PI
for (const x of xs) {
use(x);
}
const { a, b } = object;
use(a, b);