'randFoods' is never reassigned. Use 'const' instead
10const url = "https://api.itadakimasu.app";
11
12function gen(len) {
13 let randFoods = [];14 let generated = "";
15 //add the ingredients first
16 for (let i = 0; i < len - 1; i++) {
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);