Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Accessing properties by name
Message
 
 
À
Tous
Information générale
Forum:
Javascript
Catégorie:
Codage, syntaxe et commandes
Titre:
Accessing properties by name
Divers
Thread ID:
01667529
Message ID:
01667529
Vues:
44
UPDATE. Never mind, solved it.

Hi everybody,

I'm wondering how can I make the second function generic (e.g. utilize the column name instead of using quantity):
adjustmentLinesLabelsPrintingController.prototype.total = function (column) {

        let result = 0;
        if (this.model && this.model.lineItems) {
            result = _.sumBy(this.model.lineItems, column);
        }
        return result;
    };

    adjustmentLinesLabelsPrintingController.prototype.totalPositive = function (column) {

        let result = 0;
        if (this.model && this.model.lineItems) {
            result = _.sumBy(this.model.lineItems, function (o) {
                return Math.abs(o.quantity); // Here what is the correct syntax to use column?
            });
        }
        return result;
    };
Thanks a lot in advance.
If it's not broken, fix it until it is.


My Blog
Répondre
Fil
Voir

Click here to load this message in the networking platform