Hallo Matthias,
console.log(parseInt(Math.log10(Math.abs( 5.5))) + 1) // 1 console.log(parseInt(Math.log10(Math.abs( 0.5))) + 1) // 1 console.log(parseInt(Math.log10(Math.abs( -0.5))) + 1) // 1 console.log(parseInt(Math.log10(Math.abs( -5.5))) + 1) // 1 console.log(parseInt(Math.log10(Math.abs(-15.5))) + 1) // 2
probier mal
console.log(parseInt(Math.log10(Math.abs( 0.05))) + 1);
ich denke, abs reicht nicht, man sollte schon >=1 abfragen.
Gruß
Jürgen