Using Reduce Method Javascript