How do you round a number to one decimal place in JavaScript?

I agree you approach is right @kusha.kpr, however, if you want a string with exactly one decimal place (even if it’s zero), try toFixed(1):

const roundedStr = num.toFixed(1);

This returns a string like “2.30” or “1.00”. It rounds properly and always shows one decimal digit. If you want it back as a number, wrap it with parseFloat().