Group Array By Field Javascript Interview Coding Question