Update 08_day_objects.md

Placing variable c inside if block will justify the comment "we can not access c because c's scope is only the if block"
pull/214/head
Rahul Reddy 4 years ago committed by GitHub
parent 07143be3b7
commit 31ab79bde5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -102,12 +102,12 @@ let a = 'JavaScript' // is a global scope it will be found anywhere in this file
let b = 10 // is a global scope it will be found anywhere in this file let b = 10 // is a global scope it will be found anywhere in this file
function letsLearnScope() { function letsLearnScope() {
console.log(a, b) // JavaScript 10, accessible console.log(a, b) // JavaScript 10, accessible
let c = 30
if (true) { if (true) {
// we can access from the function and outside the function but // we can access from the function and outside the function but
// variables declared inside the if will not be accessed outside the if block // variables declared inside the if will not be accessed outside the if block
let a = 'Python' let a = 'Python'
let b = 20 let b = 20
let c = 30
let d = 40 let d = 40
console.log(a, b, c) // Python 20 30 console.log(a, b, c) // Python 20 30
} }

Loading…
Cancel
Save