tel-ran-de / FE12-Basic

2 stars 12 forks source link

HW 2020-11-02 #75

Open isalexlog opened 4 years ago

isalexlog commented 4 years ago

Task 1 Create constructor function for Address class with the following fields:

Add to Person class address field that will contain Address object (you can do it via Person.prototype.address = new Address()).

Add to Person class function sayAddress() that returns the all address fields concatenated with space between field values.

Create object pushkin of class Person with following values:

Call on this object function sayAddress() and make sure it returns no address

Populate address fields of pushkin object with following values:

Call on this object function sayAddress() and make sure it now returns the address of Alexander Pushkin.

Add value returned by sayAddress() function to the bio function result.

Task 2

Given constructor function:

function Shape(name, sides, sideLength) {
  this.name = name;
  this.sides = sides;
  this.sideLength = sideLength;
}

Add a new method to the Shape class's prototype, calcPerimeter(), which calculates its perimeter (the length of the shape's outer edge) and logs the result to the console. Create a new instance of the Shape class called square. Give it a name of square and a sideLength of 5. Call your calcPerimeter() method on the instance, to see whether it logs the calculation result to the browser DevTools' console as expected. Create a new instance of Shape called triangle, with a name of triangle and a sideLength of 3. Call triangle.calcPerimeter() to check that it works OK.