0

Why is my code crashing my app?

could anyone please tell me why this code wont run? everytime I run it code playground goes blank and wont run any other codes until the app is restarted. https://code.sololearn.com/WxyYNtz79XaW/?ref=app

18th Oct 2018, 3:36 AM
DazVonHelmet
DazVonHelmet - avatar
3 Respuestas
+ 4
for(j=i+1;j<pickedCards.length;j++){
18th Oct 2018, 3:41 AM
Calviղ
Calviղ - avatar
+ 2
DazVonHelmet Unfortunately, I can get the app to hang again if I manually insert duplicates. It looks to me that you're changing the object over which you're iterating (the for loop iterates over arr and you use arr.splice inside the loop), which can lead to problems. https://stackoverflow.com/questions/16217333/remove-items-from-array-with-splice-in-for-loop That thread explains more in-depth handling for iterating in the same direction you're splicing, such as: ~ iterating in the opposite direction ~ creating a new array ~ .filter
18th Oct 2018, 4:39 AM
Kirk Schafer
Kirk Schafer - avatar
0
I used the same nested for look technique in this code and it worked. 🤔🤔 https://code.sololearn.com/WUA7bHz3Pox1/?ref=app
18th Oct 2018, 3:51 AM
DazVonHelmet
DazVonHelmet - avatar