I'm struggling to populate an array using a while loop. Even though the length of the array indicates that there is data present, attempting to access the data at specific indices returns undefined.
var test = [];
while (i < 16)
{
test[i] = i;
i++;
console.log(test.length);
console.log(test[i]);
}
Console output:
1
Fibbo.html:48 undefined
Fibbo.html:47 2
Fibbo.html:48 undefined
Fibbo.html:47 3
Fibbo.html:48 undefined
Fibbo.html:47 4
Fibbo.html:48 undefined
Fibbo.html:47 5
Fibbo.html:48 undefined
Fibbo.html:47 6
Fibbo.html:48 undefined
Fibbo.html:47 7
Fibbo.html:48 undefined
Fibbo.html:47 8
Fibbo.html:48 undefined
Fibbo.html:47 9
Fibbo.html:48 undefined
Fibbo.html:47 10
Fibbo.html:48 undefined
Fibbo.html:47 11
Fibbo.html:48 undefined
Fibbo.html:47 12
Fibbo.html:48 undefined
Fibbo.html:47 13
Fibbo.html:48 undefined
Fibbo.html:47 14
Fibbo.html:48 undefined
Fibbo.html:47 15
Fibbo.html:48 undefined
Fibbo.html:47 16
Fibbo.html:48 undefined