getify / You-Dont-Know-JS

A book series on JavaScript. @YDKJS on twitter.
Other
178.87k stars 33.44k forks source link

scopes-closures ch.5 'let/var' slip #1641

Closed indiagolph99 closed 4 years ago

indiagolph99 commented 4 years ago

Fixing variable declaration in first section of 'loops' part

var keepGoing = true;
while (keepGoing) {
    let value = Math.random();
    if (value > 0.5) {
        keepGoing = false;
    }
}

where keepGoing is meant to be let