Posted: Thu Jun 04, 2020 2:44 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.
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.
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!