Why is my answer wrong for this question? JavaScript Variables and Data Types Quiz

Hi there and welcome to the forum!
Did you try to run this code?
Please give a link to this step

1 Like

I find it odd the second option is not correct; strings are immutable in JS so option 1 and 3 are false and this code will not throw an error

hmm… it could be a bug.

why do you think it will not throw an error?

Sorry, tried it in another online compiler, did not show anything

ah, so you used a compiler that is not in strict mode, that is quite unusual nowadays, strict mode seems to be the default.

Now that I think about it I don’t think we added strict mode to the curriculum

learn more about it here: Strict mode - JavaScript | MDN

2 Likes

This question obviously needs to be updated.


Also, the semicolon question is wrong/ambiguous as well. Sometimes semicolons are required. That is the hole point of why the “correct” answer says “to avoid potential issues in code”. They are literally required with some code.

Hey, thanks. By the way, I was using Firefox Developer Edition. after running the code like this:
"use strict"; let name = "Andy"; name[0]="M";
on the console I have got the error message

The course has not, so far, explained about strict mode versus non strict mode. I tried the code on the DevTools and didnt get an error either. So maybe updating the question or the course would be handy as I just came across the same issue of getting the question marked as wrong and had no idea why :slight_smile:

that’s the point of creating an issue, and it has been closed, that means that changes will be live at next deployment

1 Like