exercise1.js
JavaScript/modules/module2-intermediate/code-examples/lesson1/exercise1.js
// Exercise 1: Scope Understanding
let globalVar = "global";
function testScope() {
let localVar = "local";
console.log("Inside function - global:", globalVar);
console.log("Inside function - local:", localVar);
}
testScope();
console.log("Outside function - global:", globalVar);
// console.log("Outside function - local:", localVar); // Error!
Articoli correlati
exercise1.js
exercise1.js — javascript source code from the JavaScript learning materials (JavaScript/modules/module1-foundations/code-examples/lesson1/exercise1.js).
Leggi l'articolo →exercise2.js
exercise2.js — javascript source code from the JavaScript learning materials (JavaScript/modules/module1-foundations/code-examples/lesson1/exercise2.js).
Leggi l'articolo →exercise3.js
exercise3.js — javascript source code from the JavaScript learning materials (JavaScript/modules/module1-foundations/code-examples/lesson1/exercise3.js).
Leggi l'articolo →hello.js
hello.js — javascript source code from the JavaScript learning materials (JavaScript/modules/module1-foundations/code-examples/lesson1/hello.js).
Leggi l'articolo →exercise1.js
exercise1.js — javascript source code from the JavaScript learning materials (JavaScript/modules/module1-foundations/code-examples/lesson2/exercise1.js).
Leggi l'articolo →exercise2.js
exercise2.js — javascript source code from the JavaScript learning materials (JavaScript/modules/module1-foundations/code-examples/lesson2/exercise2.js).
Leggi l'articolo →