const a = parseInt(prompt('enter 1 no ')); const sum = Math.sqrt(a); console.log(sum); document.getElementById('root').innerHTML =`<h1> ${sum} </h1>`; --------------------------------------------------- precision code 4.1 3.3000000000000003 7.789999999999999 3 0.3666666666666667 If you don’t want or need the precision shown above, you can format a number to a fixed precision: var x = 3; var y = 1.1; var z = x * y; print(z.toFixed(2)); // displays 3.30
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter