Variables declared with let can only be reassigned by
code below the declaration. The assignment will crash with a
ReferenceError if you assign to the variable.
function getNumberOfChocolates() { return 3; }
let shouldEatChocolates = true;
if (shouldEatChocolates) {
chocolates = 0;
}
let chocolates = getNumberOfChocolates();
To fix this error, move the declaration above the assignment:
function getNumberOfChocolates() { return 3; }
let shouldEatChocolates = true;
let chocolates = getNumberOfChocolates();
if (shouldEatChocolates) {
chocolates = 0;
}
You cannot reassign variables declared with const, and
you cannot reference a variable declared with const above
its declaration. The assignment will crash with a
ReferenceError if you run the code.
let timeElapsed = 31;
let pie = "cooking";
if (timeElapsed > 30) {
pi = "cooked";
}
const pi = 3.14;
To fix this error, assign to a different variable or declare a new
variable with a different name:
let timeElapsed = 31;
let pie = "cooking";
if (timeElapsed > 30) {
pie = "cooked";
}
const pi = 3.14;
export function let() {
console.log("access permitted");
}
To fix this error, name the function something other than
let, or declare the function separately with a different
name and use export-as:
export function allow() {
console.log("access permitted");
}
function allowAccess() {
console.log("access permitted");
}
export { allowAccess as let };
A function or variable name includes a Unicode escape sequence, and
the escape sequence refers to a character which isn't allowed in a
function or variable name:
let guitar\u2604 = "\uD83C\uDFB8";
let handc\uffed = true;
To fix this error, use the code point of a Unicode character which is
allowed, or remove the extraneous backslash from the name:
let guitar\u3604 = "\uD83C\uDFB8";
let handcuffed = true;
The initial character in a function or variable name can be any of the
following:
ID_Start
$
_
Characters after the initial character in a function or variable name
can be any of the following: