function sameChars(chars) { return Array.prototype.every.call(chars, function(element, index, array) { return element === array[0]; }); } alert( [sameChars('aaa'), sameChars('aab')] );
var re = /^(.)\1*$/; alert( [re.test('aaa'), re.test('aab')] );