Skip to content

Instantly share code, notes, and snippets.

@gladchinda
Created April 18, 2018 09:39
Show Gist options
  • Select an option

  • Save gladchinda/a8c086a80f486a07f3e5d48d2eae906f to your computer and use it in GitHub Desktop.

Select an option

Save gladchinda/a8c086a80f486a07f3e5d48d2eae906f to your computer and use it in GitHub Desktop.
function displaySummary({ name, scores: { maths = 0, english = 0, science = 0 } = {} } = {}) {
console.log('Hello, ' + name);
console.log('Your Maths score is ' + maths);
console.log('Your English score is ' + english);
console.log('Your Science score is ' + science);
}
// Calling without a student argument
displaySummary();
// Hello, undefined
// Your Maths score is 0
// Your English score is 0
// Your Science score is 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment