-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathajexercise6.js
More file actions
36 lines (29 loc) · 872 Bytes
/
ajexercise6.js
File metadata and controls
36 lines (29 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//Evaluate these:
//#1
[2] === [2]
{} === {}
//#2 what is the value of property a for each object.
const object1 = { a: 5 };
const object2 = object1; //{ 4: 5 }
const object3 = object2; //{ 4: 5 }
const object4 = { a: 5}; //{ a: 5 }
object1.a = 4;
//#3 create two classes: an Animal class and a Mamal class.
// create a cow that accepts a name, type and color and has a sound method that moo's her name, type and color.
class Animal {
constructor(sound,name, type, color){
this.sound = sound;
this.name = name;
this.type = type;
this.color = color;
}
makeSound(){
console.log(`${this.sound} My name is ${this.name}, I am a ${this.type} and My color is ${this.color}`)
}
};
class Mamal extends Animal{
constructor(sound,name, type, color){
super(sound, name, type, color)
}
}
const mamal1 = new Mamal('Moo','Sara', 'cow', 'black and white');