I initially solved the problem, but I realised that I donât understand it, I will just explain my thought process and ask a question after that:
before even âdebuggingâ the code, I did not understand why are there 6 0s in every row, the way I understood it is that since row is initiated outside the for loop, in the function, then every time it is changed, it remains that way, so when filled up with 2 0s initially, pushed into newArray and then when row is filled up with another 2 0s and pushed again, row is changed globally, so the previously pushed row is also changed and now has 4 0s, and then 6, do I understand this correctly?
if that is the case, I understand why when setting the row = ; IN THE BEGINNING OF THE FIRST FOR LOOP, that it gets reset, every time the loop is run, and do I understand correctly, that it gets initiated first - then filled up with 2 0s the first time, pushed into new array and for now that would be the end, does that mean that when reset now, as the loop runs again, that the previous row pushed into newArray will become empty, until row is filled up again?
And lastly, if that last /first bit is true, why is it that, when the row variable is GLOBAL, and SET IN THE FUNCTION (like in the base code of the challenge) and if I put row = ; AT THE END of the first for loop, after pushing row into newArray, why does the code still work, instead of having the final thing done in the program being row = and so all pushed rows into newArray to = , creating 3 empty rows into newArray
PLEASE HELP ME I AM LOST