0

I want to round a float value to a float with 1 digit after decimal point.

const value_1 = 58.65;
const value_2 = 58.25;

const round = (v) => {
  return parseFloat((v).toFixed(1));
}

console.log(round(value_1), round(value_2));

Above code, It's print 2 value are 58.6 and 58.3

Why value_1 after round equal 58.6, that not is 58.7

Vũ Anh Dũng
  • 980
  • 3
  • 13
  • 32

0 Answers0