Answered step by step
Verified Expert Solution
Question
1 Approved Answer
provide the comments in each line of the code let courses = [ { code: APC100, name: Applied professional communication,
provide the comments in each line of the code let courses = [ { code: "APC100", name: "Applied professional communication", hours: 3, url: "http:/www.senecacollege.ca" }, { code: "IPC144", name: "Introduction to C programming", hours: null, url: "http:/www.senecacollege.ca/ipc" }, { code: "ULI101", name: "Linux and the Internet", hours: 4, url: "http:/www.senecacollege.ca/lin" }, { code: "IOS110", name: "Windows Operating System", hours: 4, url: "http:/www.senecacollege.ca/ios" }, { code: "EAC150", name: "College English", hours: 3, url: null } ]; // Remove the last course let lastCourse = courses.pop(); // Print the last course console.log("The last course in the array is:"); console.log(`tcode: ${lastCourse.code},`); console.log(`tname: ${lastCourse.name},`); console.log(`thours: ${lastCourse.hours}`); // Create a new course let BTI225 = { code: "BTI225", name: "Web Programming Principles", hours: 4, url: "http:/www.senecacollege.ca/web" }; // Add it to the courses array courses.push(BTI225); //Find the total number of hours in all courses let totalHours = 0; for(let i = 0; i < courses.length ; i++){ if( courses[i].hours != null){ totalHours += courses[i].hours; } } console.log(`Total hours for all courses: ${totalHours} hours.`); // Student function constructor function Student(name, dob, sid, program, gpa){ this.name = name; this.dob = dob; this.sid = sid; this.program = program; this.gpa = gpa; } // To string Student.prototype.toString = function(){ let result = `Student info for ${this.name}:`; result += `tDate of Birth: ${this.dob.toLocaleString()},`; result += `tStudent ID: ${this.sid},`; result += `tProgram: ${this.program},`; result += `tGPA: ${this.gpa}`; return result; } // Students array let students = []; // Create 4 students and push it to the array let s1 = new Student("Your Name", new Date(Date.UTC(1997, 9, 15)), "1000", "IFS", 9.9); students.push(s1); let s2 = new Student("Name1", new Date(Date.UTC(1998, 4, 20)), "1001", "ABC", 7.5); students.push(s2); let s3 = new Student("Name2", new Date(Date.UTC(1996, 11, 29)), "1002", "DEF", 8.6); students.push(s3); let s4 = new Student("Name3", new Date(Date.UTC(1999, 1, 1)), "1003", "GHI", 5.9); students.push(s4); // Print all the students for(let i = 0 ; i < students.length ; i++){ console.log(students[i].toString()); } // Function to find the highest GPA function highGPA(studentsArray){ let highestGPAStudent = studentsArray[0]; for(let i = 1 ; i < students.length ; i++){ if(highestGPAStudent.gpa < studentsArray[i].gpa){ highestGPAStudent = studentsArray[i]; } } return highestGPAStudent; } // Find the print the student with highest GPA let student = highGPA(students); console.log(student.toString());
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Sure Heres the code with comments added javascript let courses code APC100 Course code name Introduction to Programming Course name credits 3 Number o...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started