Question: The following code initializes a few variables. Your code should begin with these variables and use them subsequently as indicated: const course_id = 'CSC441'; const





The following code initializes a few variables. Your code should begin with these variables and use them subsequently as indicated: const course_id = 'CSC441'; const section = 'H001'; const university='usm'; const term = 'spring, semester'; const year = 2021; (1) Let Courseltem be a function that takes a single argument called props. Inside the function use the typeof operator to check if the type of props is 'object'. If it is an object then print each key, value pair on a separate line using console.log. If props of type 'string' then it should print it as is and immediately return. In case props is an object and has a year property, then, return an object that has the year as the key whose value is an object with the rest of the key-value pairs of props For example the return value for the about data would be ( 2021/ 'course id''CSC4413 'section': 'H001', etc } }. Other than a year and a corresponding value, I will use totally different key-value pairs to test your code. In other words, you cannot assume that the props I pass would have a key called course_id or a value "CSC441 (2) Pass all the variables initialized above in a single call to Courseltem without changing the number of parameters the function takes. Make sure that the function prints the variable name and its value one per line. (3) Complete the following code: let arr = [1,2,3].map(YOUR FUNCTION HERE) Note that (1,2,3) is an array and map function is defined on the Array object. Read about Array on MDN. Your function should call Courseltem and pass the same keys with different values each time map calls it. The return value of Courseltem should be the return value of your function. After the above line add a console.log(arr) to print the contents of arr. (4) Watch my videos about array destructuring and object destructuring. Complete the function status shown below: const status = ({year, university, ...rest)) => { Ilif the year is before 2020, print "pre Covid" and if the year is after 2021 print "post Covid" l/otherwise print "in Covid pandemic" 1/if the university is usm then print "Hattiesburg", misu then print "Starkville", um then print 1/"Oxford" (function continues in the next page) //print rest as is (5) Call the status function using the array you created in part (3). For each element of the array pass all the key-value pairs. Again, I will use totally different key-value pairs to test you code. So, don't hardcode any key value pairs (other than year and university, of course)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
