Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accessing properties by name
Message
 
 
To
All
General information
Forum:
Javascript
Category:
Coding, syntax & commands
Title:
Accessing properties by name
Miscellaneous
Thread ID:
01667529
Message ID:
01667529
Views:
43
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
Reply
Map
View

Click here to load this message in the networking platform