Using Reduce Method Javascript Array Slice