I am trying to show an array loop in which i have a date and its value. I am able to loop Objects.keys of an array but inner loop need to show the key array individualy. Its a task of simple arrays but i'm unable to figure it out. following is my code.
var arr = {
'2016-03-06' : ['1', '2','3','4','5'], // 6th march 2016
'2016-03-07' : ['6','7','8','9','10','11'], // 7th march 2016
'2016-03-08' : ['2','3','4','5'], // 8th march 2016
'2016-03-09' : ['6','7','8','9','10','11'], // 9th march 2016
'2016-03-10' : ['1', '2','3'], // 10th march 2016
'2016-03-11' : ['6','7','8','9','10','11'], // 11th march 2016
};
var a=0;
var b=0;
ab = Object.keys(arr).length;
bc = Object.keys(arr)[b].length;
console.log(ab);
console.log(bc);
for(a=0; a < ab; a++){
$('.result .array').append('<li data-date="'+Object.keys(arr)[a]+'">'+ Object.keys(arr)[a] + '</li>');
for(b=0; b < Object.keys(arr).length; b++){
$('.result .array').append('<li data-date='+ Object.keys(arr)[a] +'>1</li>');
}
}
abshould be namedobjectLengthandbcshould be namedfirstIndexLength, etc.forloops ?Object.keys(arr)[b]this will always give you10. Its length of2016-03-06and not['1', '2','3','4','5']