TIMEX TIMEX - 4 months ago 7
Javascript Question

How do I go through each element in this javascript object and print out each name?

thejson = [ { name: 'Jany', id: '1246956' },
{ name: 'Azeez', id: '2246306' },
{ name: 'William', id: '22525926' },
]


How do I use a "foreach" loop and print out each name?

Answer
var i;
for (i = 0; i < thejson.length; i++) {
    alert(thejson[i].name);
}