javascript - Proper lodash method -
i have objected named slip, object contains property active attr '1', when slip object not selected property active has attr '0'.
i have function need apply when property active has attr '0'. want know best lodash method use here in case
var applystraightwin = function(slip, amount) { var moneyline = _.result(_.find(slip.lines, {isselected: '1'}), 'moneyline'); _.filter(slip.active, function(pickactive) { if (pickactive == '1') { _.assign(slip, { win: amount, risk: riskwincalculations.calculatestraightbet(amount, parsefloat(moneyline, 10), false), riskselected: false, winselected: true }); } }); } that _.filter method doind want, taking out slip.active != 0. but, background, there better use _.filter method ?
[...] there better use
_.filtermethod
absolutely: not using better.
var moneyline = _.result(_.find(slip.lines, {isselected: '1'}), 'moneyline'); if (slip.active == '1') { _.assign(slip, { win: amount, risk: riskwincalculations.calculatestraightbet(amount, parsefloat(moneyline, 10), false), riskselected: false, winselected: true }); } the purpose of _.filter select subset of collection. not right function use if want test whether property has specific value.
Comments
Post a Comment