I’m majorly struggling to understand the newArray.push(callback(this[i], i, this)); part of the solution
why are there 3 parameters used inside the callback function here, this[i] indicates the current element, I get that, but why and how are i and this used??
I’d love a detailed explanation
Thanks!!
haha nvm chatgpt explained it to me lol, I was confused what would happen to the ‘i’ and ‘this’ cz we won’t be needing it in every function, and my dumbass didn’t realize the parameters will only be passed and not utilized
It is up to the consumer of your map API if they need the index and the array map was called upon. As you are expected to implement the same API as the official map method it must pass the same arguments to the callback.