Get help with Code for Teens
- Joined:Thu Jun 04, 2020 2:34 am
I just bought this book for my teenager, and was going through the first chapter this week before him. In the "Simple Errors" section of Chapter 1, I could not reproduce the Identifier has already been declared
error with the syntax given. I tried to invoke strict mode in the console, but it didn't seem to "take," and the only way I could get that favoriteColor changing error was to declare a function, and invoke "use strict"; within the function body.
Code: Select all
let favoriteColor = "red";
// Response: undefined // no problem yet (undefined just means "nothing to tell you")
let favoriteColor = "blue";
// Response is supposed to be: Uncaught SyntaxError: Identifier 'favoriteColor' has already been declared
// I just get Response: undefined again!
Did I miss a step where you can configure the Chrome dev tools JS console to be in strict mode? Is there an errata published for the book? Did I miss something? Please advise.
- Site Admin
- Joined:Mon May 14, 2018 10:19 pm
Very observant, mkeCharlie!
Since the book was published, Chrome has gotten more forgiving about reassigning with `let`. It doesn't throw the error anymore. The practice hasn't changed; just Chrome's implementation of it.