v1
5/28/2020 by ygorbunkov 5/28/202000
Setup HTML - click to add setup HTML
disable setup JavaScript
Setup JavaScript
const n = Math.PI,
      precision = 6
delete caserun single casemove downdrag and drop case


ready



function toFixed(num, fixed) {
    var re = new RegExp('^-?\\d+(?:\.\\d{0,' + (fixed || -1) + '})?');
    return num.toString().match(re)[0];
}

console.log(toFixed(n, precision))
delete caserun single casemove upmove downdrag and drop case


ready



const toFixed = (n,p) => {
const nStr = `${n}`,
	number = nStr.slice(0, nStr.indexOf(".")+p+1)
return Number(number)
}

console.log(toFixed(n,precision))
delete caserun single casemove updrag and drop case


ready



const limitPrecision = (n,p) => (0|n*10**p)/10**p
      
console.log(limitPrecision(n, precision))
Test Case - click to add another test case
Teardown JS - click to add teardown JavaScript
Output (DOM) - click to monitor output (DOM) while test is running
RUN