function round(a, b, c) {
var roundformat = c
var d = a / b
var result = Math.round(d)
console.log(result)
}
For example I want to rounding then format the number based on arguments c:
If c = 4
Output is: 5,3333
If c = 2
Output is: 5,33
function round(a, b, c) {
var d = a / b;
var result = d.toFixed(c);
console.log(result);
}
round(8, 3, 3);