//Task 1 - Object Creation (10 points) Create an object named student with the following properties: let student = { //Create an object called student firstName: "Man", lastName: "Tran", age: 19, courses: ["Web Programming", "OOP_JAVA", "Perspectives on World Issues"] //Create a courses array } //Task 2: Object Manipulation (15 points) Add the following properties and methods to the student object: student.addCourse = function(courseName){ //create a methods to the student object to add a course this.courses.push(courseName); //Add a course into the courses array console.log(`${courseName} has been added to your course library.`); } student.removeCourse = function(courseName){ //create a methods to the student object to remove a course if (student.courses.includes(courseName)){ //Using .includes in this condition statement to make sure the course is in the courses array. Otherwise, it will pass to the else statement. this.courses.slice(student.courses.indexOf(courseName),1) //Using .slice to remove a course from the courses array. Moreover, .indexOf(courseName),1 is to find the index number of the removing course, and 1 is the quantity. console.log (`${courseName} has been removed from your course library`); } else{ console.log(`There is no course named ${courseName} in your course library`); } } student.getInfo = function(){ return `Student name: ${student.firstName} ${student.lastName}\nAge: ${student.age}`// Output: Student name: Man Tran // Age: 19 } //Task 3: Object Access (10 points) Create a function that accepts the student object as a parameter and displays the list of courses the student is studying. Call this function and display the course list. function courseDisplay(student){ //Create a function that responsibles for listing the courses the student are enrolled in. console.log(`Student ${student.firstName} ${student.lastName} is currently enrolled in: ${student.courses.join(", ")}.`); } courseDisplay(student); //Call the function //Task 4: Object Iteration (15 points) Create an object named grades with the following properties: let grades = { // Create a grades object "Math":"A-", "Literature" : "C", "English" : "B" }; function gradesDisplay(grades){ //Create a function that prints out the list of courses and their grades for (let courses2 in grades){ //let course2 in grades means assigns course2 as a name of keys (courses) => for (let courses2 in grades) means this loop keeps running until all of the courses2 are listed console.log(`${courses2}: ${grades[courses2]}` ); //courses2 are the courses, grades[courses2] are the values of the corresponding keys } } gradesDisplay(grades); //call the function // Task 5: Object Inheritance (10 points) Create a new object named internationalStudent that inherits from the student object. Add a property called country to the internationalStudent object, representing your home country. let internationalStudent = Object.create(student); //Create an internationalStudent object that are copied from the student object internationalStudent.country = "Viet Nam"; //Add a country property into internationalStudent object //Task 6: Object Comparison (10 points) Create a function that compares the student and internationalStudent objects. Determine if they are the same student based on their first name, last name, and age. Display a message indicating whether they are the same student or not. function studentComparison(student, internationalStudent){ //Create a function to compare internationalStudent object and student object if(student.firstName == internationalStudent.firstName && student.lastName == internationalStudent.lastName && student.age == internationalStudent.age){// if T/F * T/F * T/F console.log("They are the same student"); } else{ console.log("They are not the same student"); } } studentComparison(student, internationalStudent); //call the function