Last active
July 30, 2018 19:21
-
-
Save mosijava/e00f3282f7b4d5d5e24fcfde8e7a9a9c 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
class Human { | |
constructor (gender,nationality){ | |
this.gender = gender; | |
this.nationality = nationality; | |
} | |
humanIntro (){ | |
var sex = this.gender == "female" ? "girl" : "boy"; | |
return `I'm a ${sex} from ${this.nationality}`; | |
} | |
} | |
class Person extends Human{ | |
constructor(name,lastName,gender,nationality){ | |
super(gender,nationality); | |
this.name = name; | |
this.lastName = lastName; | |
} | |
introduce (){ | |
console.log (`${this.humanIntro()} and my name is ${this.name} ${this.lastName}`); | |
} | |
} | |
let me = new Person("mostafa","Javaheripour","male","Iran"); | |
me.introduce(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment