Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function logScope() {
- // this could also be var localVar = 2
- let localVar = 2;
- if (localVar) {
- let localVar = "I'm different";
- console.log("nested localVar: ", localVar);
- }
- // localVar that is in the logScope function
- console.log("logscope localVar: ", localVar);
- }
- // run the function
- logScope();
- // another example using let
- function lotsOfApples() {
- let localApples = "green apples";
- if (localApples) {
- let localApples = "rotten apples";
- console.log("nested let variable:", localApples);
- }
- console.log("entire scope let variable: ", localApples);
- }
- lotsOfApples();
- // an example of using a const
- const MYHOMEWORK = "Programming with Javascript";
- console.log(MYHOMEWORK);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement