Reduce Function In Javascript Array Of Objects