0

What's wrong with my array?

Please check the code https://code.sololearn.com/W0z7zI82F3Kp/?ref=app

2nd Sep 2019, 8:57 AM
Fernando Moceces
Fernando Moceces - avatar
2 Answers
+ 1
Quick Answer : Push a copy of z instead, with z.slice() https://code.sololearn.com/WLD9cbMKKPMv/?ref=app Explanation : Because you are adding the reference of z instead of the value of z to a, that's why when z changes, all elements of a is changed. https://www.sololearn.com/post/136566/?ref=app https://www.sololearn.com/post/136211/?ref=app More in : https://code.sololearn.com/WKKkpq0efxai/?ref=app
3rd Sep 2019, 11:01 AM
Gordon
Gordon - avatar
0
Gordon thank you very much, man!
4th Sep 2019, 12:04 AM
Fernando Moceces
Fernando Moceces - avatar