Let's look at another method that calculates useful information about an object.
Here we have an object square with asideLength property to represent the length of the square's side. This time, we have added a new method, calcPerimeter, which computes the perimeter of the square. Notice we make use of the keyword return (in the same way we use it in functions!).
Instructions
Add another method called
calcArea
, which returns the area of square
in terms ofsideLength
. Use the calcPerimeter
function as a guide.
No comments:
Post a Comment