javascript - Loop through multiple values within an object -


what i'm trying pretty simple. have this:

var looptest = {      test1: {                 date : ['november 2011', 'a new date']               },      test2: {                 date : 'january 2012'               }  }; 

and using for...in so:

for(var key in looptest) {     $('.content').append('- '+looptest[key].date+'<br />'); } 

i want make test1.date values display separate elements. currently, they're 1 string. how go this?

here's fiddle: jsfiddle

keep short , sweet

for (var key in looptest) {     [].concat(looptest[key].date).foreach(function(date) {         $('.content').append('- ' + date + '<br />');     }); } 

http://jsfiddle.net/aft37vq8/6/


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -