Ruby Array Reduce Method In Js