Hi can someone tell me why I can't instantiate the following class/object?
function Arbitrage(odds1, odds2, investment)
{
this.investment = investment;
this.odds1 = odds1;
this.odds2 = odds2;
this.arbPercent = function() {
return 1.0/this.odds1 + 1.0/this.odds2;
};
this.profit = function() {
return this.investment / this.arbPercent() - this.investment;
};
this.individualBets = function() {
return {
odds1bet : this.investment/this.odds1/this.arbPercent(),
odds2bet : this.investment/this.odds2/this.arbPercent()
};
};
};
module.exports = Arbitrage;
I'm calling it like this:
var utility = require('../businesslogic/utility');
...
router.post('/calculate', function(req, res)
{
var arbit = new utility.Arbitrage(req.body.odds1, req.body.odds2, req.body.investment);
res.json({
arbPercentage : arbit.arbPercent(),
profit : arbit.Profit(),
indvBets : arbit.individualBets()
});
});
The first line, var arbit = new utility.Arbitrage(...) is throwing the error.
It says TypeError: undefined is not a function
I've checked that utility isn't null or anything like that. Also all the constructor arguments are ok.
I'm not very familiar with javascript, any help would be appreciated. Thanks.
Arbitrage?