To view solutions, open the file /Day4/index.html
in your browser.
Do not forget to open the Developer panel and see the section Console
.
Task:
Complete the function in the editor. It has two parameters: a
and b
. It must return an object modeling a rectangle
that has the following properties:
length
: This value is equal toa
.width
: This value is equal tob
.perimeter
: This value is equal to2 * (a + b)
.area
: This value is equal toa * b
.
Solution:
In js/rectangle-object.js
.
Task:
Complete the function in the editor. It has one parameter: an array, a
, of objects. Each object in the array
has two integer properties denoted by x
and y
. The function must return a count of all such objects o
in array a
that satisfy o.x == o.y
.
Solution:
In js/count-objects.js
.
Task:
Create a Polygon
class that has the following properties:
- A constructor that takes an array of integer values describing the lengths of the polygon's sides.
- A
perimeter()
method that returns the polygon's perimeter.
Locked code in the editor tests the Polygon constructor and the perimeter method.
Solution:
In js/classes.js
.
Return to navigation list