Replacing var keyword

@JeremyLT and other mods

This is a tangent from this post, but is there some rule that we can’t use let or const declarations in the problem sets until they’re introduced, or are the problem sets just showing their age? With regards to the Stand In Line problem in the linked post, if the testArr weren’t being declared with var then it wouldn’t even be possible to reference inside the function definition.

I understand it would be a quite an undertaking at this point, but I agree with what you said the other day that ES6 is not special in 2021, and really think it would be reasonable to go through and change all of the instances of var in the curriculum.

This is not quite right. The variable testArr is being defined in global scope so the function nextInLine would be able to directly access it no matter whether var, or let, or const was used.

1 Like

Yes, but not in the position that it’s declared in at present (underneath the function definition), since let and const declarations don’t get hoisted like var declarations do.

Regardless, I’m talking about the entirety of the curriculum, not only this problem.

Or so I thought… Whoops. Maybe not.

Totally wrong. Please disregard my mumblings.

1 Like

You can test this in the challenge itself. Change it to let or const and then do a console.log(testArr) in the function.

But I agree with your overall argument, in an ideal world it would be a good idea to get rid of var in all of these challenges. I’m not an authority on this but I believe that they are concentrating on the next version of FCC right now and thus don’t want to spend the time to go back and fix this with the limited resources they have.

1 Like

Ah, I hadn’t heard about the new version. Well, I hope things are modernized in the process. For now I’ll just try to ignore the vars.

I think we’ve tried to eleminate the use of var downstream of the ES6 section, but I’m sure a PR to fix any stray ones in the rater challenges would probably be received positively.

there is this in progress by @scissorsneedfoodtoo

Then I think that we can work on replacing all remaining instances of var after that

1 Like