Fidelity Investments Interview Question

In JavaScript, how would you count the number of each item in an array, such as ["A", "B", "C", "A", "A"].

Interview Answer

Anonymous

Apr 12, 2016

Iterate through the array in a for loop, and setup a counter/iterator for each element. The interviewer said that was the wrong answer, so I asked him what the answer was -- and he wrote out a for loop with a counter/iterator -- Pretty much exactly what I told him the answer was. This has never happened to me before in an interview - the interviewer flat-out lied when he said my answer was wrong. Or maybe he didn't understand the word "counter" - his English was pretty bad.

2