Tell us what’s happening:
Hi there, I’m just looking for clarification. Correct me if I am wrong but I don’t recall any reference to const before this challenge. I understand I’m probably supposed to search about it (in fact I did) but I would have appreciated a lesson on it before this challenge.
At first, it seemed to me that the else part of the example code was continuously reassigning a value to const, which, if I am correct, is forbidden, but then it occurred to me that that happens in different blocks, and thus allowed. Am I correct? Please enlight me
Your code so far
// Only change code below this line
// Only change code above this line
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:78.0) Gecko/20100101 Firefox/78.0.
Now, const means the value stored in the variable will not be changed. For numbers, this is easy. The number won’t change. For array, it is a bit different. The memory location won’t change, which is to say, you cannot change which array you are looking at or where it is stored, but you can modify that array.
Use const if you can. This is for variable data that won’t change.
Use let if you must. This is for variable data that must change.
Use var never.
It’s a bit of a mistake to have const in the example code considering it has not been taught yet. But such inconsistencies can happen over time as challenges are updated (PR with updates). It really has to do with the age of the curriculum and how it has been updated over time.
You will learn about let and const in the next part of the curriculum (ES6) which is only one challenge away.
Yes, I’m looking forward to it!
Keeping the order of how concepts are introduced can be challenging with such a large amount of challenges. But in this case, I think it’s just a bit of an oversight.
The example code is more “correct” using const from a best-practices perspective, but “incorrect” from a pedagogic point of view. When you are more experienced it’s easy to forget how little things like using a variable declaration that hasn’t been taught yet can throw someone off that has just started to learn.
It may seem like a small thing to someone experienced but for new learners, it can be very jarring and just introduce confusion and an extra mental burden for no good reason. In my opinion, it probably should be fixed. Really, by now, const and let should be part of the basic JS part of the curriculum (likely will be in time).
Jokes apart, you’re obviously right. It was a little jarring seeing const all of a sudden without having encountered it before. Maybe (as recursion was already treated in a previous challenge) a little explanation in the ‘Use Recursion to Create a Countdown’ lesson could suffice for the moment, leaving a deeper exposition for the following ones. But then again, if const and let should be treated earlier in the curriculum that won’t be necessary.