Skip to content

Instantly share code, notes, and snippets.

@mosijava
Last active July 30, 2018 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mosijava/e00f3282f7b4d5d5e24fcfde8e7a9a9c to your computer and use it in GitHub Desktop.
Save mosijava/e00f3282f7b4d5d5e24fcfde8e7a9a9c to your computer and use it in GitHub Desktop.
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