Filter on Dynamics JavaScript?

I picked up the following JavaScript I’m a novice on JS. Anyway I want to achieve if emailsignature isdefault not equals 0 then add the handler email signature, below is the code, how do I do this?, where would I insert this IF condition?

//find the users signature dynamically

var query = "?$select=title,safehtml&$filter=ownerid/ownerid eq " + signatureUserId;

Xrm.WebApi.retrieveMultipleRecords("emailsignature", query).then(
function success(result) {

//The below for each goes through all the email signatures and it looks like the code is grabbing the first signature on the list. How do I code a filter to add default? 
// I want to only add the isdefault signature to the email, i.e. if signarure not equal to NO add.

for (var i = 0; i < result.entities.length; i++) { //This is itterating through all the signature
var emailSig = result.entities[0];
if (emailSig != null) {
                                
if (emailDescription === "<p></p>" ||  emailSubject === null ) 
                {
                                var signatureDynamic = emailSig["safehtml"];
                                formContext.getAttribute("description").setValue("<br /><br />" + signatureDynamic);
}
else if (emailSubject .includes("RE:"))
{
 var signatureDynamic = emailSig["safehtml"];
                                formContext.getAttribute("description").setValue("<br /><br />" + signatureDynamic + emailDescription);
}
                            }
                            break;
                        }
                    },
                        function (error) {
                        alert("Error: " + error.message);
                    });
                    //end users signature
                
            }

            break; // We will grab the first one
        }
    },
        function (error) {
        alert("Error: " + error.message);
    });

 
}