0

I need to round a number up to two digits, I'm currently using toFixed(2) but it doens't round it, I've Googled / Stack Overflow'ed but couldn't really find an answer for my situation:

const value = -0.004;
console.log(value.toFixed(2)); // 0.00
// Expected: -0.01

Anyone a clue? Keep safe.

randomKek
  • 1,108
  • 3
  • 18
  • 34
  • `console.log(value.toFixed(2)); // -0.00` – Rayon Apr 14 '20 at 06:19
  • 1
    `Number.prototype.toFixed()` rounds to the nearest integer/decimal. 4 is closer to 0, so it is rounded towards 0.00 instead of 0.01. – Terry Apr 14 '20 at 06:34

0 Answers0