Reputation: 1159
I have an array storing some data in the following format
var arrayTest = [{
"firstName": "SOUM!",
"lastName": "Ghosh"
}, {
"firstName": "Fred",
"lastName": "Twilliger"
}, {
"firstName": "Snoop",
"lastName": "Krieg"
}
]
I am trying to parse each key items
here is my script
var html = "";
$.each(arrayTest, function () {
html + = this.firstName;
});
alert(html);
what am I doing wrong.
Here is my fiddle http://jsfiddle.net/sghoush1/J2ssK/6/
Upvotes: 0
Views: 52
Reputation: 218
$.each(arrayTest, function (i, row) {
html += row.firstName;
});
Upvotes: 0
Reputation: 164776
String concatenation is so last century
var html = arrayTest.map(function(n) {
return n.firstName;
}).join('');
Upvotes: 0
Reputation: 7654
SyntaxError: Unexpected token =
So... you can't have a space between +
and =
Upvotes: 2