79532437

Date: 2025-03-25 00:32:28
Score: 1.5
Natty:
Report link

For powers of 10 there's a very silly method, but it's probably the easiest to remember?

x=1234;
nearest10=(("" + x).length - 1) * 10;

although this returns 0 for, eg: 3.5, I guess you could go:

nearest10_1 =(("" + x).length - 1) * 10
nearest10=nearest10_1 === 0 ? 1 : nearest10_1;

You asked for the "most efficient". I don't know what axis you were measuring that on. CPU time? Heat? Programmer time?

Reasons:
  • Has code block (-0.5):
  • Ends in question mark (2):
Posted by: nic ferrier