-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjects.js
More file actions
50 lines (38 loc) · 1.37 KB
/
objects.js
File metadata and controls
50 lines (38 loc) · 1.37 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Using creator functions
// Creating Objects
let Car = {
name : "Tesla",
price : 50000,
hasAutoPilot : function() {
return(console.log("Has AutoPilot")); // Has AutoPilot
}
};
function HouseKeeper(name, age, yearsOfExperience, languages) {
this.name = name;
this.age = age;
this.yearsOfExperience = yearsOfExperience;
this.languages = languages;
};
// get full summary using prototype
HouseKeeper.prototype.getFullSummary = function() {
return(`${this.name} has ${this.age} years of experience and knows ${this.languages}`);
}
// function getFullSummary(obj) {
// return(`${obj.name} is a ${obj.age} year old ${obj.yearsOfExperience} years experience housekeeper with ${obj.languages} languages`);
// };
var houseKeeper1 = new HouseKeeper("Annie", 22, 2, ["English", "Yoruba"]);
// Annie is a housekeeper with 2 years of experience and knows English and Yoruba.
// log annie.getFullSummary()
console.log(houseKeeper1.getFullSummary());
// console.log(getFullSummary(houseKeeper1));
function Apartment(name, numOfRooms) {
this.name = name;
this.numOfRooms = numOfRooms;
};
var house1 = new Apartment("Shalom Place", 20); // Shalom Place has 20 rooms.
var house2 = new Apartment("Eagles Pride", 22);
function User(userName, email, password) {
this.userName = userName;
this.email = email;
this.password = password;
};