I'm trying to do a simple exercise but I think I'm over thinking it. I getting values from a Json:
{
"films": [
    {
        "title": "Platoon",
        "director": "Bob",
        "synopsis": "<p>Lorem ipsum dolor sit amet</p>",
        "genre": ["action"]
    },
    {
        "title": "Alien",
        "director": "Jack",
        "synopsis":"<p>Lorem ipsum dolor sit amet</p>",
        "genre": ["action,horror"]
    },
    {
        "title": "Goonies",
        "director": "Danielle",
        "synopsis":"<p>Lorem ipsum dolor sit amet</p>",
        "genre": ["action,comedy"]
    },
    {
        "title": "Spiderman",
        "director": "Sam",
        "synopsis":"<p>Lorem ipsum dolor sit amet</p>",
        "genre": []
    }
]
}
and putting them in a html like so:
$(document).ready(function() {
$.getJSON("films.json").done(function(data) {
    $.each(data.films, function(i) {
        $('#films').append('<div class="film">' +
        '<div class="message__title">' + data.films[i].title + '</div>' +
        '<div class="message__director">' + data.films[i].director + '</div>' +
        '<div class="message__synopsis">' + data.films[i].synopsis + '</div>' +
        '<div class="message__genre">' + data.films[i].genre + '</div>' +
        "</div>");
    });
});
});
How can I separate the genres in different html blocks (like each one in a p tag)? I tried to run another loop in the first each function but it was printing the block twice, not separating the genres.
Any help will be welcome, thank you!
 
    