Created
January 15, 2019 15:22
-
-
Save fdjones/4589bea101a63d2e0a819516fe407f62 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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