Exercise: Erasing circles
Modify the code in the following ways:
- Add a method to create a string with information about a circle.
- Add a method to determine the area of a circle.
- Print the results of both methods to the console whenever a circle is drawn or erased.
- As each circle is entered using the form, add it to an array.
- Add an event listenerA function that is executed when an event occurs. for the erase button so that when the index in the array is provided, the corresponding circle is "erased" by having a white circle with a radius of one pixel greater drawn over it.
Note:
Hints:
Add the methods to the function
CircleInfo
.
Solution to the exercise
Here is one possible solution.
Note:
Hints:
- undefined
1
2
window.onload = startFunction;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
<!DOCTYPE html>
<html lang="en">
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX