I am trying to make it so that when I run the function it checks if there is a save already. If there isn't, then it puts those values in the list. I am using nested arrays and there will be three total saves. But for some reason when I run it, it says that allSaves[L] is undefined. But when I put a zero in for the L, it works. But I can't do that. So does anyone know how I could fix that? Here is my code -
function savingList(principal, interestRate, time, compoundNumber) {
var allSaves = new Array();
allSaves[0] = new Array();
for(var L = 0; L < 2; L++) {
if(allSaves[L].length == 0){
allSaves[L] = new Array(principal, interestRate, time, compoundNumber);
}
}
}