Skip to content

Latest commit

 

History

History
49 lines (29 loc) · 1.34 KB

README.md

File metadata and controls

49 lines (29 loc) · 1.34 KB

10 Days of Javascript - Day 4

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.

Day 4: Create a Rectangle Object

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 to a.
  • width: This value is equal to b.
  • perimeter: This value is equal to 2 * (a + b).
  • area: This value is equal to a * b.

Solution:

In js/rectangle-object.js.

Day 4: Count Objects

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.

Day 4: Classes

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