noc-book-2 icon indicating copy to clipboard operation
noc-book-2 copied to clipboard

The drawCircle parameter named "radius" is actually the diameter (section 8.2)

Open sidwellr opened this issue 3 years ago • 1 comments
trafficstars

In section 8.2, Recursion, the three examples contain a drawCircle function to demonstrate recursion. The last parameter to this function is named "radius", but it is passed to ellipse() as the width parameter, which is actually the diameter. It works fine since JavaScript doesn't care what names you give your variables, but calling the diameter "radius" may be confusing for humans trying to understand the code!

sidwellr avatar Sep 01 '22 18:09 sidwellr

Section 9.13 has a similar issue. The text says "The creature will have a radius" and the code has a variable "r", but "r" is the diameter, not the radius.

sidwellr avatar Oct 03 '22 21:10 sidwellr

This has been fixed in chapter 8, removing the label but leaving open for when I get to chapter 9.

shiffman avatar Mar 29 '23 13:03 shiffman

chapter 9 draws the floops with this.r * 2 now!

shiffman avatar Oct 08 '23 15:10 shiffman