-4

Here is the code:

    var negativeOdds = document.getElementById("negative").value;
    var positiveOdds = document.getElementById("positive").value;

    console.log(positiveOdds);

    var positiveImplied = 100 / (positiveOdds + 100);

The result for var = positiveImplied is always something like 0.000843 when it's supposed to be around 0.454. I've tried countless of combinations with the parenthesis and it still gives me the same random answers. I console logged the positiveOdds variable to make sure it's getting the right info and it clearly is.

Anyone know what's up?

What I forgot to add is that it works perfectly fine in the other scenario:

var negativeOdds = document.getElementById("negative").value;
    var positiveOdds = document.getElementById("positive").value;

    console.log(positiveOdds);

    var positiveImplied = (100) / (positiveOdds + 100);
    var negativeImplied = (-(negativeOdds))/((-(negativeOdds)) + 100);

Works fine for negativeImplied, doesn't work at all for positive.

Edit: Works fine with parseInt. But still I don't understand how I don't have to use parseInt for negativeImplied, but have to for positiveImplied.

Mabeh Al-Zuq Yadeek
  • 46
  • 4
  • 16
  • 28

1 Answers1

1

Use Number

var negativeOdds = Number(document.getElementById("negative").value);
var positiveOdds = Number(document.getElementById("positive").value);
var positiveImplied = 100 / (positiveOdds + 100);
Bonatti
  • 2,778
  • 5
  • 23
  • 42