Dynamic array problem

Here’s a poser. I have a series of dynamic arrays using the push and splice methods. The arrays are populated by variables representing numbers. Each time the variables are moved in and out of the various arrays, I loop through each array and add up the numbers in each, thus changing the total number for each array. That total number is achieved with a number variable that starts at 0 and is added to as the array is looped through by +=. The total number then is transferred to a text field. All of this works very nicely.

The problem: When one of the arrays is empty, I would like for the text field to represent that by showing a “0”. But what happens is the last number in that array when it only had one item in it stays in the text field after the array is emptied even though the value transfers to the new array that it’s been pushed into. Obviously that’s because when the array is empty it has no values to += the total variable.

I’ve tried various conditional statements along the lines of:

if (thisArray*>=0&&thisArray*<thisArray.length){
totalVariable+=thisArray*;
}else{totalVariable=0};

The first part of the conditional statement works just fine because there is an i value in the thing, but the second part doesn’t work because when you loop through an empty array, it simply registers nothing at all? I was hoping when I looped through the empty array and traced it, I might get a “null”. I could use that in a conditional statement, but the trace simply shows nothing at all.

Can anybody think of a conditional statement that might change the totalVariable to 0? Or some other solution?

Ha ha. I’m stumped.