| 1 | |
| 2 | |
| 3 | class Person { |
| 4 | constructor(firstName, lastName, age, country, city) { |
| 5 | this.firstName = firstName |
| 6 | this.lastName = lastName |
| 7 | this.age = age |
| 8 | this.country = country |
| 9 | this.city = city |
| 10 | this.score = 0 |
| 11 | this.skills = [] |
| 12 | } |
| 13 | getFullName() { |
| 14 | const fullName = this.firstName + ' ' + this.lastName |
| 15 | return fullName |
| 16 | } |
| 17 | get getScore() { |
| 18 | return this.score |
| 19 | } |
| 20 | get getSkills() { |
| 21 | return this.skills |
| 22 | } |
| 23 | set setScore(score) { |
| 24 | this.score += score |
| 25 | } |
| 26 | set setSkill(skill) { |
| 27 | this.skills.push(skill) |
| 28 | } |
| 29 | getPersonInfo() { |
| 30 | let fullName = this.getFullName() |
| 31 | let skills = |
| 32 | this.skills.length > 0 && |
| 33 | this.skills.slice(0, this.skills.length - 1).join(', ') + |
| 34 | ` and ${this.skills[this.skills.length - 1]}` |
| 35 | |
| 36 | let formattedSkills = skills ? `He knows ${skills}` : '' |
| 37 | |
| 38 | let info = `${fullName} is ${this.age}. He lives ${this.city}, ${this.country}. ${formattedSkills}` |
| 39 | console.log(this) |
| 40 | return info |
| 41 | } |
| 42 | static favoriteSkill() { |
| 43 | const skills = ['HTML', 'CSS', 'JS', 'React', 'Python', 'Node'] |
| 44 | const index = Math.floor(Math.random() * skills.length) |
| 45 | console.log('hi') |
| 46 | return skills[index] |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | console.log(Person.favoriteSkill()) |
| 51 |
nothing calls this directly
no outgoing calls
no test coverage detected