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.
Try as below and let me know
var a = new Array();
a[0]= new Array();
a[0].push(1);
a[0].push(2);
a[0].push(3);
console.log(a[0][0]);
console.log(a[0][1]);
console.log(a[0][2]);