Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hello I need help with one assignment is already on the last part:Message from professor:For getCoursesBySubject service, you'll first want to import the courses module
Hello I need help with one assignment is already on the last part:Message from professor:For getCoursesBySubject service, you'll first want to import the courses module from models. This will provide you with an object with a find method that you can use to filter the list of all courses by the subject input gotten from the URL parameter. To do this, you can call find on the imported object and pass it a function that when receiving a course object like the zeroth one in the Array in courses.json:add:"textbooks":"","coursecode":"ACC "name":"Accounting I","type":"","faculty":"Bier, Diana","seatsopen":""status":"Open","schedule":"TR : AM: PM; Main Campus, Adelaide B Wilbur Arts Center","credits":""begindate":""enddate":"returns true when this object's coursecode property starts with the subject input. Remember that since find is asynchronous, you'll need to use an await. You can then return this result. This can all be done in one line. Let me know if you have any questions about this. I can review this function when you're done, and then we can move to the getCoursesByGenEdCategory functionThis is what my code is lookig like:class CourseServices async getCoursesBySubjectsubject return subject; async getCoursesByGenEdCategorycategory return category; moduleexports new CourseServices;These are the instructions of what to do:For the getCoursesBySubject service, now make it an async function because you'll need to await the result from the Model class. Import the courses model. Change the implementation return the result of calling the find method to get all courses whose course code starts with the given subject. Note that the return statement will need to have an await since the function is asynchronous. We'll also want to do something similar for the general education courses but there we'll only be getting the general education courses which are currently offered next semester. So first we'll use the result of calling await to get all the courses and form a Set of the codes. Then we'll return all gened courses in that category whose codes are in this set.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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