Complete the code to declare a variable with block scope using let.
let [1] = 5; console.log(x);
The variable x is declared using let, which has block scope and is hoisted but not initialized.
Complete the code to declare a constant variable.
const [1] = 10; console.log(value);
The constant variable value is declared with const and cannot be reassigned.
Fix the error in accessing a let variable before declaration.
console.log([1]); let a = 3;
Accessing a before its declaration causes a ReferenceError due to the temporal dead zone of let.
Fill both blanks to create a block-scoped variable and log it.
{
[1] x = 7;
console.log([2]);
}var which is function-scoped.Using let declares a block-scoped variable x, which can be logged inside the block.
Fill all three blanks to declare a constant and log its value.
const [1] = 20; function show() { console.log([2]); } show(); console.log([3]);
The constant PI is declared and logged inside and outside the function.
