at the same time? Bit confused as I don’t believe I have done a lesson where you plainly have two variables assigned to the exact same thing. Is this because it is a number? and not a string? The lesson does not address it and I would like to write an explanation in my notes, thanks!
Another question, where do i find the lesson on accumulators? I know there are lessons on operators though cannot find any lesson with ‘accumulator’ in the title and I was just shown one in the last lesson and could not figure out how it worked exactly, google helped a little though there is a listen within this that did teach me of accumulators yeah? I can not remember them for the life of me though so I am beginning to think i did not do a lesson on them at all.
Your code so far
// Setup
const myArr = [2, 3, 4, 5, 6];
// Only change code below this line
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0
Challenge Information:
Basic JavaScript - Iterate Through an Array with a For Loop
Forget the accumulator question, it did explain how it worked, it said i -= 2 would DECREASE the increment by 2 so if += it would INCREASE, sorry figured that one out just now
Why would two different variables containing the same value be an issue?
Just like two people can have the same name and not be the same person. The person is the variable and their name is the value.
The variables can’t have the same name(*) but the values they contain can be the same. There is nothing wrong with that and it has nothing to do with the data type of the value.
(*) There is a little more to it. They can’t be named the same in the same scope and depending on how the variable is declared what happens is different. When using let or const it is an error, when using var it will overwrite (the last variable wins).
I see, I see, with more experience i’ll come to understand the complexities. I imagine it is much to early to try and clarify every small thing. But that makes sense, 2 different people, same name. Thanks for knowledge!