Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function foo() {
let res = ''
let j = 10
for(let i=0; i<j; i++) {
// uncommenting ... the following line causes error
// var j = 5
res += `${j}, `
j -= 1
}
res += `${j}`
console.log(`foo: ${res}`)
}
function bar() {
let res = ''
let j = 10
for(let i=0; i<j; i++) {
let j = 5
res += `${j}, `
j -= 1
}
res += `${j}`
console.log(`bar: ${res}`)
}
function baz() {
let res = ''
var j = 10
for(let i=0; i<j; i++) {
var j = 5
res += `${j}, `
j -= 1
}
res += `${j}`
console.log(`baz: ${res}`)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment