L
L
lavezzi12015-11-22 20:44:22
JavaScript
lavezzi1, 2015-11-22 20:44:22

Question about rounding?

Hello!
js newbie, please help.
There is a simple calculator.

function calcReturn(amount, days) {
      return amount+days*(amount*0.058);
  }


When some digits are combined, it produces numbers like 125.19999999999999. How to round? I found the Math.round method, but how do I apply it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Lebedev, 2015-11-22
@lavezzi1

function calcReturn(amount, days) {
      return Math.round(amount+days*(amount*0.058));
  }

A
amatory10, 2015-11-22
@amatory10

Math.round(125.19999999999999);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question