Skip to content

Instantly share code, notes, and snippets.

@fdjones
Created January 15, 2019 15:22
Show Gist options
  • Save fdjones/4589bea101a63d2e0a819516fe407f62 to your computer and use it in GitHub Desktop.
Save fdjones/4589bea101a63d2e0a819516fe407f62 to your computer and use it in GitHub Desktop.
const getNameWithInitial = function () {
let initial = this._gender === 'male' ?
'Mr. ' :
'Mrs. ';
return initial + this._name;
}
export class Person {
constructor(name, gender) {
this._name = name;
this._gender = gender;
}
get name() {
return getNameWithInitial.call(this);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment