Scope

 let sum = 71; //GLOBAL SCOPE

function calSum(a, b) {
  let sum = a + b; //FUNCTIONAL SCOPE
}
console.log(sum);
sum(4,5);




//WORKS
function outer() {
  let x = 5;
  let y = 6;
  function inner() {
    let z = 33;
    console.log(x);
    console.log(y);


  }
  console.log(z);


  inner();
}
outer();

// PRACTICE
let greet = "Helloo";
function changeGreet() {
  let greet = "namasthe..";
  console.log(greet);
  function inner() {
    console.log(greet);
  }
}
console.log(greet);
changeGreet();




Comments

Popular posts from this blog

Callback Hell

TODO list with DOM

Refactoring callback hell code