Periksa apakah array memiliki nilai javascript yang sama
const allEqual = arr => arr.every(v => v === arr[0]);
allEqual([1,1,1,1]); // true
TC5550
const allEqual = arr => arr.every(v => v === arr[0]);
allEqual([1,1,1,1]); // true
// how to check all values of an array are equal or not in javascript
const allEqual = (arr) => arr.every(val => val === arr[0]);
console.log(allEqual([1, 2, 3, 4, 5, 6])); // false
console.log(allEqual([1, 1, 1, 1])); // true
[1,1,1,1].every( (val, i, arr) => val === arr[0] ) // true
const allEqual = arr => arr.every( v => v === arr[0] )
allEqual( [1,1,1,1] ) // true
function myFunction( arr ) {
return new Set(arr).size === 1
}