-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path06-objects.js
More file actions
36 lines (27 loc) · 853 Bytes
/
06-objects.js
File metadata and controls
36 lines (27 loc) · 853 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
const debu = {
firstName: 'Debabrata',
lastName: 'Das',
birthYear: 1997,
job: 'Web Developer',
friends: ['Debu', 'Nick', 'Nikhil'],
hasDrivesLicense: true,
// calcAge: function (birthYear) {
// return 2025-birthYear;
// }
// calcAge: function () {
// console.log(this);
// return 2025 - this.birthYear;
// }
calcAge: function () {
this.age = 2025 - this.birthYear;
return this.age;
},
getSummary: function () {
return `${this.firstName} is a ${this.calcAge()}-year old ${debu.job}, and he has ${this.hasDrivesLicense ? 'a' : 'no'} driver's license.`
}
};
console.log(debu.calcAge());
console.log(debu.age);
// Problem
// "Debabrata is a 28-year old Web Developer, and he has a driver's license."
console.log(debu.getSummary());