Skip to content

Instantly share code, notes, and snippets.

@abhikulshrestha22
Last active July 25, 2019 17:25
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 abhikulshrestha22/67f3c01e885068053745e258dad98c8f to your computer and use it in GitHub Desktop.
Save abhikulshrestha22/67f3c01e885068053745e258dad98c8f to your computer and use it in GitHub Desktop.
var fruit1 = {
name: 'Apple',
quantity: 2,
}
var fruit2 = {
name: 'Mango',
quantity: 4,
}
function getString(personName) {
return `${personName} have ${this.quantity} ${this.name} remaining`
}
console.log(getString.call(fruit1, 'John Doe'));
// John Doe have 2 Apple remaining
console.log(getString.call(fruit2, 'Jane Doe'));
// Jane Doe have 4 Mango remaining
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment