I have a variable that looks like this:
const percent = (props.students.length / totalStudentsProgram) * 100;
It returns 44.444444444444% How can I round it so that it looks like 44.4%
I have a variable that looks like this:
const percent = (props.students.length / totalStudentsProgram) * 100;
It returns 44.444444444444% How can I round it so that it looks like 44.4%
Call .toFixed
will return a string with the appropriate number of decimal places.
var str = percent.toFixed(1) + '%';