The code from the Learn JavaScript the Hard Way module JavaScript Level 1 exercises. This is a mirror of the code I have in the book, so if you're struggling you can use this to compare against your attempts.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

16 lines
391 B

const var_sucks = () => {
var var_scope = 10;
let let_scope = 20;
console.log(`>>> var_sucks before if: var=${var_scope}, let=${let_scope}`);
if(true) {
var var_scope = 100;
let let_scope = 100;
console.log(`>>> var_sucks inside if: var=${var_scope}, let=${let_scope}`);
}
console.log(`>>> var_sucks after if: var=${var_scope}, let=${let_scope}`);
}
var_sucks();