Reputation: 434
In Javascript I have an if statement that is failing that should be passing and I cannot figure out why. Here's the structure of the if.
if(parseInt(obj.OptionCredit) > parseInt(Account.Credits))
{
true
}
else
{
false
}
When I console log the two variables I get Account.Credits = 0 and obj.OptionCredit = 0.75. With that said, 0.75 > 0 should return false.
Can anyone help me out with this? Thank you!
Upvotes: 0
Views: 96
Reputation: 166
You are parsing them as ints (not floats), so they both return zero. 0 is not greater than 0, so the comparison returns false.
Upvotes: 3