I will be loading information into a JSON file and then importing it into firebase for it to load on my website. I have a sample JSON like this...
{
"date": "date of event",
"title": "title of event",
"address": "address",
"city": "city of event",
"state": "HI",
"zip": "11111",
"available": true,
"cost": "$60",
"included": [
"string1",
"string2",
"string3"
]
}
I have the following code.
database.ref().child('events').once('value', function(snapshot) {
if (snapshot.exists()) {
var content = '';
snapshot.forEach(function(child) {
var val = child.val();
content +='<tr>';
content += '<td>' + val.date + '</td>';
content += '<td>' + val.title + '</td>';
content += '<td>' + val.address + '</td>';
content += '<td>' + val.city + '</td>';
content += '<td>' + val.state + '</td>';
content += '<td>' + val.zip + '</td>';
content += '<td>' + val.cost + '</td>';
content += '<td>' + val.included + '</td>';
content += '</tr>';
});
$('#ex-table').append(content);
}
});
Everything is fine except for the included portion. Right now, this will print like string1,string2,string3. How would I loop through that array and either print them like..
String 1
String 2
String 3
Or even convert the string values into img. For example, if we offer coffee, or food, it'll be an icon representing that.