Skip to content

Instantly share code, notes, and snippets.

@deleteman
Created July 17, 2019 15:49
Show Gist options
  • Save deleteman/c3715cc94c989970db30a15280477243 to your computer and use it in GitHub Desktop.
Save deleteman/c3715cc94c989970db30a15280477243 to your computer and use it in GitHub Desktop.
class Person {
constructor(name) {
this.name = name
}
}
function greet(person) {
console.log(this.greeting.replace("$", person.name))
}
let english = {
greeting: "Hello there, $"
}
let spanish = {
greeting: "Hola $, ¿cómo estás?"
}
let people = [new Person("Fernando"), new Person("Federico"), new Person("Felipe")]
people.forEach( greet, english)
people.forEach( greet, spanish)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment