Skip to content

Instantly share code, notes, and snippets.

@pszponder
Created June 20, 2021 03:32
Show Gist options
  • Save pszponder/8a406d88fead2518fea409b030fd357d to your computer and use it in GitHub Desktop.
Save pszponder/8a406d88fead2518fea409b030fd357d to your computer and use it in GitHub Desktop.
// Define variable x and initialize its value to 1
let x = 1;
// Define function that will console.log the value of x
function myFunc() {
console.log(x);
}
// Define function that defines a local variable x = 50 and calls myFunc()
function logVariable() {
let x = 50;
myFunc();
}
// What will logVariable() return? 1, 50, something else?
logVariable(); // This will log 1 to the javascript console
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment