Strict Mode?

Get help with Code for Teens
Post Reply
mkeCharlie
Posts:1
Joined:Thu Jun 04, 2020 2:34 am
Strict Mode?

Post by mkeCharlie » 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.

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.

JeremyMoritz
Site Admin
Posts:20
Joined:Mon May 14, 2018 10:19 pm
Location:Kansas
Contact:

Re: Strict Mode?

Post by JeremyMoritz » Sat Mar 27, 2021 2:42 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.

Thanks!

Jeremy
Jeremy Moritz
Author of Code for Teens
www.CodeForTeens.com

User avatar
ChinaawamP
Posts:45
Joined:Thu Dec 30, 2021 7:53 pm
Location:Bulgaria
Contact:

-

Post by ChinaawamP » Sun Jan 23, 2022 12:46 am

Since I changed drawing mode to 'line', now when I select Freehand the tool is not working properly. It's not my pencil, as pencil works on iPad in google draw. In freehand mode, the drawing lags, there is a line 'in the air' ie not on the screen that appears, and the nib is not the location where the marks are appearing. The drawing is stilted and not controllable

Post Reply