I dont see a definition for data in your code, but from using $.each, I will assume it to be an Array of Objects.
“If a record shows null”… shows null for what? place_name? address? area_code? list_size? any of the above?
Does the record actually contain null? Or does it not contain the key if the value is null?
From the looks of your code…
$('#txt-search').keyup(function(){
if(searchField === '') {
$('#filter-records').html('');
return;
}
var re = new RegExp(searchField, "i");
var output = "<div class=\"info\">"+(data.filter((x) => x.hasOwnProperty('place_name') && x.place_name.match(re)).map((item) => "<h4>"+item.place_name+"</h4><p>"+item.address+"<br> Tel: (0" + item.area_code + ')' + item.phone + '</p><p>Practice List Size: ' + item.list_size + '</p>').join("</div><div class=\"info\">"))+"</div>";
$('#filter-records').html(output);
}
By definition, any place_name that is null would not match the regex, and would automatically be filtered…
But to stick to your own code, jQuery’s $.each has a feature in which you can short the loop in a continue-like behavior by returning a non-false value;
and if i were smart, i’d remove the join text altogether and just put the div tags into the map function. But i’m not a smart man first thing in the morning, obviously.