'eachTimeZoneString' is never reassigned. Use 'const' instead
40 search.addEventListener("change", (e) => {
41 userInput = String(e.target.value).toLowerCase().trim();
42 let FilteredTimeZoneArray = allTimezonesArray.filter((eachTimeZone) => {
43 let eachTimeZoneString = String(eachTimeZone.textContent).toLowerCase();44 if (eachTimeZoneString.includes(userInput)) {
45 eachTimeZone.parentElement.style.display = "block";
46 return eachTimeZone;
'FilteredTimeZoneArray' is never reassigned. Use 'const' instead
39 e.preventDefault();
40 search.addEventListener("change", (e) => {
41 userInput = String(e.target.value).toLowerCase().trim();
42 let FilteredTimeZoneArray = allTimezonesArray.filter((eachTimeZone) => {43 let eachTimeZoneString = String(eachTimeZone.textContent).toLowerCase();
44 if (eachTimeZoneString.includes(userInput)) {
45 eachTimeZone.parentElement.style.display = "block";
Description
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.
Bad Practice
let pi = Math.PI
for (let x of xs) {
use(x);
}
let { a, b } = object;
use(a, b);
Recommended
const pi = Math.PI
for (const x of xs) {
use(x);
}
const { a, b } = object;
use(a, b);