Skip to content

Check if all elements in an array are equal using JavaScript

const allEqual = arr => arr.every(val => val === arr[0]);

allEqual ([1, 2, 3, 4, 5, 6]); // false
allEqual ([1, 1, 1, 1]); // true
See also  How to check the day of any date in PHP?

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.