Quickest way:
?omputational complexity is O(n).
function howMuchIsRepeated_es5(arr) {_x000D_
const count = {};_x000D_
for (let i = 0; i < arr.length; i++) {_x000D_
const val = arr[i];_x000D_
if (val in count) {_x000D_
count[val] = count[val] + 1;_x000D_
} else {_x000D_
count[val] = 1;_x000D_
}_x000D_
}_x000D_
_x000D_
for (let key in count) {_x000D_
console.log("Value " + key + " is repeated " + count[key] + " times");_x000D_
}_x000D_
}_x000D_
_x000D_
howMuchIsRepeated_es5(['a','b','c','d','d','e','a','b','c','f','g','h','h','h','e','a']);
_x000D_
The shortest code:
Use ES6.
function howMuchIsRepeated_es6(arr) {_x000D_
// count is [ [valX, count], [valY, count], [valZ, count]... ];_x000D_
const count = [...new Set(arr)].map(val => [val, arr.join("").split(val).length - 1]);_x000D_
_x000D_
for (let i = 0; i < count.length; i++) {_x000D_
console.log(`Value ${count[i][0]} is repeated ${count[i][1]} times`);_x000D_
}_x000D_
}_x000D_
_x000D_
howMuchIsRepeated_es6(['a','b','c','d','d','e','a','b','c','f','g','h','h','h','e','a']);
_x000D_