user7515543
user7515543

Reputation:

How to get upto particluar digit level in js

I am new to js.I search on googled too, but I none worked for me.

I have a var num = 71.666666666

How can I limit this to 71.66

I tried this :

Math.tranc(num,2)     # 71

and 

Math.round(num.2)     # 72

And also plese suggest me if there are any other methods in js to do this.

Please help

Upvotes: 0

Views: 35

Answers (1)

Shivkumar kondi
Shivkumar kondi

Reputation: 6762

Try this..

Math.round(num * 100) / 100

var num = 71.6666666;

a = Math.round(num * 100) / 100

console.log("output :",a);

Upvotes: 2

Related Questions