Logbook Format
Logbook Format
Logbook answersheet
Name:
MSU Enrollment Number:
Section A
Question 1:
Create an object representing a car with properties like brand, model, and year.
Access each property using both dot and bracket notation.
Answer:
// Output:
// Using dot notation:
// Brand: Toyota
// Model: Camry
// Year: 2022
// Using bracket notation:
// Brand: Toyota
// Model: Camry
// Year: 2022
Question 2: xyz
Answer: same format as Question 1
Question 3: xyz
Answer: same format as Question 1
Question 4: xyz
Answer: same format as Question 1
Section B
Question 1:
Write a function that takes a student object as input and calculates the average
score of the student. The student object should have the following structure:
javascript
Copy code
const student = {
name: "John Doe",
scores: [85, 90, 78, 92, 88]
};
Return the average score and print it in the console.
Answer:
// Function to calculate the average score of a student
function calculateAverage(student) {
// Destructure the scores array from the student object
const { scores } = student;
// Calculate the average by dividing the total score by the number of scores
const averageScore = totalScore / scores.length;
// Output:
// The average score of John Doe is: 86.60
Question 2: xyz
Answer: same format as Question 1
Question 3: xyz
Answer: same format as Question 1
Section C
Question 1:
You are given an object representing a course with properties name and students
(an array of student names). Write a function that:
Answer:
/*
Expected Output:
Updated Course: {
name: "JavaScript Fundamentals",
students: ["Alice", "Bob", "Charlie"]
}
*/
Question 2: xyz
Answer: same format as Question 1
Question 3: xyz
Answer: same format as Question 1