ReactJs Round to two decimal places

We can use native JavaScript method to round to two or more places in React JS. Here we are going to create one example to use toFixed method to format the decimal numbers to 2 decimal places.

ReactJs Round to two decimal placess | JavaScript Example

Let’s create an example to understand the toFixed() method in react.

<code>const PriceCmponent = () =>{
const price = 99.329;
return (
<div>
Price = {price.toFixed(2)}
</div>
);

}</code>

The above exmaple will produce result 99.32.

 Try Example »   

In the same way, you can pass any component as props in react.


Advertisements

Add Comment