I am using splice method to remove a subarray from an array with the following code:
for(let i = 0; i < cid.length; i++)
{
if(coinsValue[cid[i][0]] < troco && cid[i][1] > 0)
available += cid[i][1]
if(coinsValue[cid[i][0]] > troco)
cid[i].splice(0)
}
The output is :
[ [ 'PENNY', 1.01 ],
[ 'NICKEL', 2.05 ],
[ 'DIME', 3.1 ],
[ 'QUARTER', 4.25 ],
[ 'ONE', 90 ],
[ 'FIVE', 55 ],
[ 'TEN', 20 ],
[ 'TWENTY', 60 ],
[] /// removed elements from this array, but not the array itself ]
As you can see the elements that fit the condition are removed and I'm still left with an empty array. However I want to remove it completely!
Any help?