Ask coding questions
How do you round in JS?
For example: 3.0458385 to 3.046?
Rounding to 3 decimal places looks something like this:Math.round(x*1000)/1000
if you want to turn it into a function:
var number = 27/7;
// Three decimal places
function round(number, decimal_places)
return Math.round(number * Math.pow(10, decimal_places)) / Math.pow(10, decimal_places);
Hey I think it’s Math.round(number); and put the number where it says “number”But here is the link I found it from: https://www.w3schools.com/jsref/jsref_round.asp
Hope this helps!