Seeking the optimal method to determine the next decade after a given value in Javascript. For instance:
If the value is 9, the next decade would be 10^1
For 200 it would be 10^3
And for 1001, it would be 10^4
This algorithm should also cater for negative numbers:
With -9, the next decade would be -10^1
For 200, it would be -10^3
And for 1001, it would be -10^4
The term "decade" may have been inaccurately used here. Basically, what I need is the next whole number that can be expressed as a power of 10. For example, for 9, that's 10^1. And for 200, that's 10^3 since 10^2 is less than 200...