Skip to content

Instantly share code, notes, and snippets.

@luisenriquecorona
Created November 24, 2020 18:37
Show Gist options
  • Save luisenriquecorona/6f978fe2e46b1325dd564ac7f32876c3 to your computer and use it in GitHub Desktop.
Save luisenriquecorona/6f978fe2e46b1325dd564ac7f32876c3 to your computer and use it in GitHub Desktop.
CreatePerson.js
function createPerson(firstName, lastName) {
return {
firstName: firstName,
lastName: lastName,
getFullName: function() {
return this.firstName + " " + this.lastName
},
greet: function(person) {
alert("Hello, " + person.getFullName() +
". I'm " + this.getFullName());
}
};
}
var johnDoe = createPerson("John", "Doe");
var janeDoe = createPerson("Jane", "Doe");
johnDoe.greet(janeDoe);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment