79371399

Date: 2025-01-20 13:06:21
Score: 0.5
Natty:
Report link

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

Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Tom Barden