I have if statement like:
if((gotPrice * price.value).toFixed(0) >= answers.MINIMUM_BUY_AMOUNT) {
...
}
Results are
(gotPrice * price.value).toFixed(0) = 0
and
answers.MINIMUM_BUY_AMOUNT = 200
Then it fall to true! not sure in what world 0 is greater or equal to 200!!
I also tried this way but results was the same
if((gotPrice * price.value).toFixed(0) >= Number(answers.MINIMUM_BUY_AMOUNT).toFixed(0)) {
...
}
sample:
var x = 0.3431;
var y = 1.5467;
var z = '200';
console.log((x * y).toFixed(0) >= z); // false (but in my case says true!)
Any suggestions?
ToFixed converts number to string, calculations should be done with numbers
var x = 0.3431;
var y = 1.5467;
var z = parseInt('200');
console.log(Math.round(x * y) >= z);