-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMethods.js
36 lines (31 loc) · 951 Bytes
/
Methods.js
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
/*---------------------------------------------------------
author: kallol chakraborty
program no: 012
program description: Methods
time complexity:
space complexity:
date: 28/08/2021
----------------------------------------------------------*/
// creating a new object
var newObject01 = {
// key: value
firstName: 'Kallol',
lastName: 'chakraborty',
role: 'developer',
skills: [],
addSkills: function (skill) {
this.skills.push(skill);
},
countSkills: function () {
return `${this.firstName} ${this.lastName} has ${this.skills.length} no. of skills.`;
},
};
// printing 0 skills as no skill is added
console.log(newObject01.countSkills());
// adding skills
newObject01.addSkills('javascript');
newObject01.addSkills('ABAP/4');
// printing the number of skills added before
console.log(newObject01.countSkills());
// displating all the info
console.table(newObject01);