Function to check all elements in an array are same or not

Jira Code : BGGN-677

/**
* Function to check whether the elements in an array are same or not
* @param ItemLocArray
*/
function compareItemLoc(ItemLocArray)
 {
     let first = ItemLocArray[0];
     for (let i=1; i<ItemLocArray.length; i++)
         if (ItemLocArray[i] != first)
             return false;
     return true;
}

Leave a comment

Your email address will not be published. Required fields are marked *