[logical bug?] Basic CSS: Change the Color of Text


solution passed the tests (at the end), but I find out that it passes a test that presumably should fail in the following case:

if (true) {
    i = "block scope";
    console.log("Block scope i is: ", i);


Shouldn’t the second test fail? The variable i declared in the if statement should not be equal to “block scope” without let, right? Effectively, third test still fails…

Technically it’s not declared, but since it’s set to block scope it would actually be const not let, unless it was going to change. Really it shouldn’t pass.

1 Like

"use strict"; should make it fail, right?

It should. Since “use strict” won’t allow undeclared variables. However I’m not sure how far these challenges look into the code. Just like this one there are challenges that accept code that shouldn’t pass. So they don’t catch everything…like this one seems to be happy just as long as i is set to something

Thank you for the replies, @Cody_Biggs .

I should make it explicit that in question about "use strict"; I was referring to actual code, not the challenge specifically.

1 Like

Yes, if you use “use strict” and do not declare your variables it will give you an error. Just make sure to set it with a global scope. If “use strict” is used in a function then it will only apply to that function.

1 Like