I need condition to be true only if all properties of the object (variables) are not equal to each other. How can I condition object properties' inequality in a more optimal way? If the number of them grows the combination of obj[1]!=obj[2] and so on will grow enormously
var obj = {
1: linksArray[randomNumber],
2: linksArray[randomNumber2],
3: linksArray[randomNumber3]
}
if(obj[1]!=obj[2] && obj[1]!=obj[3] &&
obj[2]!=obj[3] && obj[2]!=obj[1] &&
obj[3]!=obj[2] && obj[3]!=obj[1]
) {
arr.push(linksArray[randomNumber]);
arr.push(linksArray[randomNumber2]);
arr.push(linksArray[randomNumber3]);
break;
}
Aucun commentaire:
Enregistrer un commentaire