30-Days-Of-React icon indicating copy to clipboard operation
30-Days-Of-React copied to clipboard

Fix wrong comments in 01_Day_JavaScript_Refresher/6.Scope/Local scope

Open hidaviddong opened this issue 2 years ago • 0 comments

wrong comments in letsLearnScope function

function letsLearnScope() {
  console.log(a, b) // JavaScript 10, accessible
  let c = 30
  if (true) {
    // we can access from the function and outside the function but
    // variables declared inside the if will not be accessed outside the if block
    let a = 'Python'
    let b = 20
    let d = 40
    console.log(a, b, c) // Python 20 30
  }
  console.log(a,b,c)  // JavaScript 10 30
  console.log(a,b,d)  // we can not access d because d's scope is only the if block
}
letsLearnScope()

hidaviddong avatar May 18 '22 15:05 hidaviddong