Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to check all values of an array are equal or not in javascript

// 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
 
PREVIOUS NEXT
Tagged: #check #values #array #equal #javascript
ADD COMMENT
Topic
Name
5+9 =