Reduce Function In Javascript Array Of Integers