Comparison logic for up to three elements is straightforward. Comparing more elements need more clever solutions.
/* manual comparison of 3 elements */ if(g === h && g === f) { "do something" } /* looping comparison of n-elements */ function nEqual(){ for (let i = 1; i < arguments.length; i++){ if ( arguments[i] === null || arguments[i] !== arguments[i-1] ) { return false; } return true; }; nEqual(a,b,c,d,e,f,g,h) && { "do something" }