Since I haven't seen it anywhere else here, I'll just add that my preferred method here would be as below. The +
operator casts to a Number
so it'll handle the trailing zeroes for you.
const foo = 123;
const bar = 123.45;
console.log(+foo.toFixed(1)); // 123
console.log(+bar.toFixed(1)); // 123.5