Here is a problem that I am facing with JavaScript and cannot seem to figure it out from the screenshot below.
The issue I'm encountering is that when checking the array in firebug, it appears to be blank with a length of 0
. However, if I click on the (+) icon, the data suddenly shows up. Can someone please assist me in identifying where I may have gone wrong with my code?
Snippet of Code Provided:
//scope.days is an array of objects
var newArr = [];
var myArr = [];
myArr = scope.days;
console.log(myArr.length);
var weekNum = 1;
newArr['week'+weekNum] = [];
for(var i=1; i<= myArr.length; i++) {
newArr['week'+weekNum].push(myArr[i]);
if(i%7 == 0){
weekNum = weekNum + 1;
newArr['week'+weekNum] = [];
}
}
scope.days = newArr;
Attached Firebug Screenshot Below: