Last active
June 27, 2019 10:20
-
-
Save Bouzazi/e73fc900ccd82eddf7915a0afe9b46fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Execute using --use_strict tag "node --use_strict classes.js" | |
class Human { | |
constructor(name, job, skills = []){ | |
this.name = name; | |
this.job = job; | |
this.skills = skills; | |
} | |
getJob(){ | |
return this.job; | |
} | |
setJob(newJob){ | |
this.job = newJob; | |
} | |
leaveJob(){ | |
this.job = "unemployed"; | |
} | |
learnNewSkill(newSkill){ | |
this.skills.push(newSkill); | |
} | |
forgetSkill(skill){ | |
this.skills = this.skills.filter(element => element !== skill); | |
} | |
} | |
class Student extends Human { | |
constructor(){ | |
super(); | |
} | |
} | |
let human = new Human("Amine", "Freelancer", ["Android", "Web", "SysAdmin"]); | |
let me = new Student(); | |
// setJob to set a Job | getJob to get a Job | |
me.setJob("Web developer"); | |
me.learnNewSkill("React"); | |
me.forgetSkill("React"); | |
me.leaveJob(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment