How to format a number using fixed-point notation in JavaScript

1 Answer

0 votes
function toFixedPoint(x, decimal_places) {
    return Number.parseFloat(x).toFixed(decimal_places); 
 }

console.log(toFixedPoint(12427453.86901, 2)); 


   
/*
run:
 
12427453.87
 
*/

 



answered Nov 21, 2024 by avibootz

Related questions

...