generated from skills/copilot-codespaces-vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
member.js
24 lines (21 loc) · 738 Bytes
/
member.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
function skillsMember() {
const member = { name: 'Alice', skills: [] };
return {
addSkill: skill => {
if (!member.skills.includes(skill)) member.skills.push(skill);
},
listSkills: () => console.log(member.skills.length ? `${member.name}'s skills: ${member.skills.join(', ')}` : `${member.name} has no skills.`),
removeSkill: skill => {
const index = member.skills.indexOf(skill);
if (index > -1) member.skills.splice(index, 1);
}
};
}
// Example usage:
const member = skillsMember();
member.addSkill('JavaScript');
member.addSkill('Python');
member.listSkills();
member.removeSkill('JavaScript');
member.listSkills();
member.removeSkill('Ruby');