Im trying to set an Object value with a function.
essentially, im trying to calculate the total values in an object up to a certain point, which is the limit variable im passing to the calculateTotal function.
seems like im doing it wrong, any suggestions?
var sc = 0.75
com = 2197.63,
user_input = 400,
f11_total = 0;
var v = {
"a": com,
"b": (com * 0.06 * sc),
"c": (com * 0.09 * sc),
"d": (215.54 * Math.pow(sc, 2)),
"e": (299.36 * sc),
"f": 328.76,
"g": ((com * 0.048) * (user_input / 400)),
"h": (com * 0.01),
"3.6": 0.036,
"total": function() {
calculateTotal(3.6);
}
};
function calculateTotal(limit) {
for (var k in v) {
if (k == limit) return (f11_total * v[k]);
f11_total += v[k];
}
}
console.log(calculateTotal(3.6));
thanks!
"total": calculateTotal(3.6)get. I realize this question is "complete" but decided to throw an alternative in the ring anyway.