I use this in a loop:
$(".somediv").append('text' + array[key].arrayelement + 'sometext'+ array[key].nextelementinArray + 'moretext']);
How do I implement this: if array[key].arrayelement is null (yeah, it can be only text 'null'), then do one thing, and if notm, then another thing?
I tried this appendable text to make 2 variables, but it did not work.
card.append('<div class="col-sm-12 col-md-6 col-lg-4"><div class="info-block bg-grey m-b-2 p-a-2"><h4 class="h4 underline-sm"> ' + response[key].firstname + ' ' + response[key].lastname + ' ' + '</h4><div class="col-sm-8 text-xs-left"> <p class="m-b-1"><b>'+ response[key].job_title + '<br>Tööruum:' + $.trim(response[key].room) + '</b></p><a href="mailto:' + $.trim(response[key].email) + '">' + $.trim(response[key].email) + '</a><p class="m-b-0">' + $.trim(response[key].phone) + ' ' + $.trim(response[key].cell_phone) + '</div><div class=" col-sm-4 text-xs-right m-b-1"><img src="' + $.trim(response[key].image) + '" class="rounded-circle lg" alt=""></div></div></div>');
Simple i get: But i dont want to see
Tööruum: ' + response[key].room
when the room value is text 'null'. I tried this inside append, where is this response[key] room.
`function(){if(response[key].room===null) {return " ";}else {return '<br>Tööruum: + response[key].room';}};
but nada.
nulllike"null"?null, not a string