0

I am trying to get the right format for my operations, I want an exponential but I would like to limit the number of displayed decimals to only 2, like for example 1.13E+2 how can I do this work? Thanks in advance

row.querySelector(".one").value = (C1 * fuel).toExponential();
row.querySelector(".two").value = (C2 * fuel).toExponential();
row.querySelector(".three").value = (C3 * fuel).toExponential(); 

enter image description here

1 Answer 1

0

You can use toFixed, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed

row.querySelector(".one").value = Number.parseFloat((C1 * fuel).toExponential(2));
1
  • 2
    .toExponential(2) does the job Oct 15, 2020 at 23:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.