Monday , September 16 2024

Analyze the code snippet: let name; let age; { let height; // 2 { // 2 let weight; // 1 // 2 console.log(name); // 1 // 2 } // 2 console.log(name); // 2 } We have access to the weight variable:

Questions BankCategory: JavaScript Essentials 1Analyze the code snippet: let name; let age; { let height; // 2 { // 2 let weight; // 1 // 2 console.log(name); // 1 // 2 } // 2 console.log(name); // 2 } We have access to the weight variable:
Analyze the code snippet:

let name;
let age;
{
    let height; 			// 2
    { 					// 2
        let weight; 		// 1 	// 2
        console.log(name); 	// 1 	// 2
    } 					// 2
    console.log(name); 		// 2
}

We have access to the weight variable:

  • in the part marked 1.
  • throughout the program.
  • in the part marked 2.
  • nowhere, as we have no access at all (the variable has not been initialized).

More Questions: JavaScript Essentials 1 – JSE1: Module 2 Test