Thanks you Chad for his solution, however it now appears to clear values from the array, here is a foreach
on the console log which shows you my situation (followed
In this case it's likely that the array item hasn't been declared as a new array. Try this:
function updateLap(kartId){
if (isNaN(driverLapNumber[kartId])) {
window.driverLapNumber[kartId] = 0;
}
//ADD ONE LAP TO THE KART ID
driverLapNumber[kartId]++;
//ADD LAP TIME FOR CURRENT LAP NUMBER
if(!driverLapTimes[kartId]){
driverLapTimes[kartId] = [];
}
driverLapTimes[kartId][driverLapNumber[kartId]] = window.lapTime;
}
Of course you could always put the declaration outside of this loop by creating a method to construct your array before hand.