Skip to content

Instantly share code, notes, and snippets.

@abhikulshrestha22
Created July 25, 2019 17:38
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/5fb82446d7a85ba9987ebc986442db90 to your computer and use it in GitHub Desktop.
Save abhikulshrestha22/5fb82446d7a85ba9987ebc986442db90 to your computer and use it in GitHub Desktop.
var fruit1 = {
name: 'Apple',
quantity: 2,
}
var fruit2 = {
name: 'Mango',
quantity: 4,
}
function getString(name1, name2, name3) {
return `${name1}, ${name2} and ${name3} have ${this.quantity} ${this.name} remaining`
}
// parameters passed as aruguments
console.log(getString.apply(fruit1,['jane','john','abraham']));
// "jane, john and abraham have 2 Apple remaining"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment