Q:

Write a JavaScript program to check whether all elements in a given array are equal or not

0

Write a JavaScript program to check whether all elements in a given array are equal or not.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

const allEqual = arr => arr.every(val => val === arr[0]);
console.log(allEqual([1, 2, 3, 4, 5, 6]));
console.log(allEqual([12, 12, 12, 12]));

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now