Skip to content

Instantly share code, notes, and snippets.

@gladchinda
Created April 18, 2018 08:12
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 gladchinda/d0941bdaeadefa6525cc4906aeba219f to your computer and use it in GitHub Desktop.
Save gladchinda/d0941bdaeadefa6525cc4906aeba219f to your computer and use it in GitHub Desktop.
const student = {
name: 'John Doe',
age: 16,
scores: {
maths: 74,
english: 63,
science: 85
}
};
function displaySummary(student) {
console.log('Hello, ' + student.name);
console.log('Your Maths score is ' + (student.scores.maths || 0));
console.log('Your English score is ' + (student.scores.english || 0));
console.log('Your Science score is ' + (student.scores.science || 0));
}
displaySummary(student);
// Hello, John Doe
// Your Maths score is 74
// Your English score is 63
// Your Science score is 85
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment