function myFunction(x) { /*var x = 0.00195;*/ var m = -Math.floor( Math.log10(x) + 1); return m; // outputs 2 }