Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Let's waste the processor solution in Creative category for Number Length by danielsan
/** I just hate the fact that I can't use arrow functions for this */
// Let's waste the processor
const numberOfCharOfAnumberAsAString = n => Math.max(...Array.from(`${n}`).keys())+1
function numberLength(value: number): number {
return numberOfCharOfAnumberAsAString(value);
}
console.log('Example:');
console.log(numberLength(10));
import assert from "assert";
// These "asserts" are used for self-checking
assert.equal(numberLength(10), 2);
assert.equal(numberLength(0), 1);
assert.equal(numberLength(4), 1);
assert.equal(numberLength(44), 2);
console.log("Coding complete? Click 'Check' to earn cool rewards!");
April 23, 2020
Comments: