function repeat(arr) {
let counter = 0,
value;
for (let i = 0; i < arr.length; i++) {
if (arr[i] === arr[i + 1]) {
counter++;
value = arr[i];
}
}
}
[1,2,3,4,4,4, 4,5,2,1,2] = > 4
function repeat(arr) {
let repeats = {},
maxValue,
maxIter;
for (let i = 0; i < arr.length; i++) {
let value = arr[i];
if (repeats[value] === undefined)
repeats[value] = 0;
++repeats[value];
if (maxValue === undefined
|| repeats[value] > maxIter) {
maxValue = value;
maxIter = repeats[value];
}
};
return maxValue;
}