A function to convert from temperatures is written below
function tryConvert(temperature, convert /*callback*/) {
const input = parseFloat(temperature);
if (Number.isNaN(input)) {
return '';
}
const output = convert(input);
const rounded = Math.round(output * 1000) / 1000;
return rounded.toString();
}
My question is this line:
const rounded = Math.round(output * 1000) / 1000;
Why the need to multiply by 1000? and also divide result by 1000?