The student record now has several scores. Extract its name properties and compute one average; use the Console to check each result.
Extract properties into variables directly:
const book = { title: "Dune", author: "Herbert", year: 1965 };
const { title, author } = book;
const { title: bookTitle } = book;
function displayBook({ title, author, year }) {
return `${title} by ${author} (${year})`;
}
displayBook(book); // "Dune by Herbert (1965)"
const scores = { Alice: 95, Bob: 82, Carol: 91 };
for (const [name, score] of Object.entries(scores)) {
console.log(`${name}: ${score}`);
}
firstName and lastName from student.fullName(student) that returns "Jordan Lee".averageScore(student) that returns the average of student.scores (rounded to 1 decimal).console.log(): "Jordan Lee — avg: 87.8".Object destructuring: const { name, age } = person;
Rename while destructuring: const { name: fullName } = person;
Use Object.entries() to loop over key-value pairs.