Sharing the entire statements in question might have been more helpful to scripting newcomers as explaining this behavior with certainty is otherwise impossible. :slightly_smiling_face:
Also, have you tested scenarios with over 50 deletion candidates? This is also just a theory that I can’t confirm with this little to go on but I don’t think your code does what you think it does due to slice/splice confusion.
Slice creates a new array.
Splice mutates the one whose length you’re checking in your conditional.
Ergo using slice will only ever give you one outcome. You want splice.
The section of code that deletes records looks like it was taken from the documentation. Notice that there are two slices. The first slice takes the first 50 records, without mutating the original array. The second slice removes the first 50 records and reassigns the variable to the new remainder. Note that in this case, the variable could not be declared with const.
Of course, using a single line with splice would also work and is more concise. But this bit of code with slice should be fine.