I am working on a task to incorporate an if statement that checks for the existence of a specific property in a JSON file. If the property exists, I need to display its value within HTML tags <div class='titleHolder'>
and
"<div class='posterHolder'>"
. I only want to include this property X between these two divs if it is present in the JSON file.
$(document).ready(function () {
$.getJSON("js/appjson.json", function (data) {
for (var i = 0; i < data.length; i++) {
$('#jsonLoad').append('<a href="movies.html?id=' + data[i].id + '" + <div class="itemsHolder">' +
"<div class='titleHolder'>" +
"<h2 >" + data[i].name + "</h2>" +
"</div>" +
"<div class='posterHolder'>" + data[i].posterPath + "</div>" +
"<div class='summaryShort'>" + data[i].summary + "</div>" +
"<div class='raiting'><p>" + data[i].imdb + "</p></div><div class='genderMovie'> " + data[i].gender + "</div> " +
"<div class='directorNdScreen'>" + 'Director by ' + " <p class='director'>" + data[i].director + '</p>' + ' ' + ' Screenplay by ' + "<p class='screenplay'>" + data[i].screenplay + "</p>" + "</div>"
+ "</a>")
}
})
});