I'm new to programming and I am starting with javascritpt, I have this code and I want the printed values to be to 3 decimal places.
<script>
for (var a = 3, b = 2; b >= 0; a ++, b --) {
document.writeln (a + " / " + b + " = " + a/b + "<br />")
}
</script>
I tried:
var a=a.toFixed(3);
var b=b.toFixed(3);
but it doesn't make a difference. The fist line comes out as 4 / 3 = 1.3333333333333333 instead of 1.333 which is what I want.