[javascript] Check if all values of array are equal

  1. Create a string by joining the array.
  2. Create string by repetition of the first character of the given array
  3. match both strings

_x000D_
_x000D_
 function checkArray(array){_x000D_
  return array.join("") == array[0].repeat(array.length); _x000D_
 }_x000D_
_x000D_
 console.log('array: [a,a,a,a]: ' + checkArray(['a', 'a', 'a', 'a']));_x000D_
 console.log('array: [a,a,b,a]: ' + checkArray(['a', 'a', 'b', 'a']));
_x000D_
_x000D_
_x000D_

And you are DONE !