Parsing data from an array

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var arrayforPrinting = [{
    "firstName": "Soumya",
        "lastName": "Ghosh",
        "profession": "Developer",
        "type": "red"
}, {
    "firstName": "Sherry",
        "lastName": "Krieg",
        "profession": "Therapist",
        "type": "white"
}, {
    "firstName": "Snoop",
        "lastName": "Krieg",
        "profession": "Dog",
        "type": "blue"
}
 
];
 
var html = "";
 
$.each(arrayforPrinting, function () {
    html += '<tr><td>' + this.firstName + '</td>';
    html += '<td>' + this.lastName + '</td>';
    html += '<td>' + this.profession + '</td>';
    html += '<td style="background:' + this.type + '"></td><tr>';
});
 
$('.dataTable').append(html);
I am grabbing the data feed at a client side variable and then iterating through the object to print the data as a list