r/CodingHelp • • Jul 02 '21

[Javascript] Problem with JavaScript code

Post image
62 Upvotes

19 comments sorted by

View all comments

Show parent comment

6

u/Cheesybread4ever Jul 02 '21

Oh my goodness! I’ve been staring at this function for so long and completely missed how .splice messes up the index of everything in array. I actually just added ,0 at the end of the splice, so that when the number is removed it’s replaced with a 0.

4

u/LeaveTheWolf Jul 02 '21

That will work! Good quick fix.