How to do two variables in an if condition? Here I have few else ifs and I want a 100 else ifs! Is there a shorter way?
$(document).on('click', '.btn-next', function () {
    var z = [];
    var recipientsArray = z.sort();
    var zDuplicate = [];
    $('option:selected.exclude_global').each(function() {
    z.push($(this).val())});
    for (var i = 0; i < recipientsArray.length - 1; i++) {
    if (recipientsArray[i + 1] == recipientsArray[i]) {
    zDuplicate.push(recipientsArray[i]);
    }else if(recipientsArray[i + 2] == recipientsArray[i]){
    zDuplicate.push(recipientsArray[i]);
    }else if(recipientsArray[i + 3] == recipientsArray[i]){
    zDuplicate.push(recipientsArray[i]);
    }else if(recipientsArray[i + 4] == recipientsArray[i]){
    zDuplicate.push(recipientsArray[i]);
    }
    }
    if(zDuplicate.length>>0){
        alert("Global Filter Already Exists");
        event.preventDefault();
    }
});
Here I have few else ifs and I want a 100 else ifs! Is there a shorter way? I have a dynamic table with dynamic rows. when my table has 5 rows the code is working, but when I have more its not working.
 
     
     
     
    