12 Problem Set

Using the following data structure (also in code insert at the bottom) create the following functions:

  1. CT course count for loop – Create a function ctCourseCount(studArr) that takes the supplied array of objects data structure as a value. When called, use a for loop to print a value for each student and the number of CT courses taken. For example: “Voski Dreher has taken 9 courses in CT.”
  2. CT course count forEach – Create a function ctCourseCountforEach(studArr) that takes the supplied array of objects data structure as a value. When called, use a forEach method to print a value for each student and the number of CT courses taken. For example: “Voski Dreher has taken 9 courses in CT.”
  3. CT students not enrolled – Create a function isNotEnrolled(studArr) takes the supplied array of objects data structure as a value. When called, the console prints a list of students that are not enrolled. For example, “Wolf Shepard” should be on that list.
  4. CT courses taken – Create a function coursesTaken(studArr) that takes the supplied array of objects data structure as a value. When called, the console prints a list of students and every course that student has taken. For example, “Wolf Shepard has taken: CT 101, CT 201, CT 137, CT 160, CT 360”
var students = [{
        name: "Diksha Dohman",
        age: 20,
        major: "Communications Technology",
        coursesTaken: ["CT 101", "CT 210", "CT 137", "CT 205"],
        totalCredits: 75,
        enrolled: true
    },
    {
        name: "Voski Dreher",
        age: 24,
        major: "Communications Technology",
        coursesTaken: ["CT 101", "CT 160", "CT 201", "CT 210", "CT 137", "CT 205", "CT 240", "CT 355", "CT 345"],
        totalCredits: 110,
        enrolled: true
    },
    {
        name: "Divya Glas",
        age: 19,
        major: "Communications Technology",
        coursesTaken: ["CT 101"],
        totalCredits: 15,
        enrolled: false
    },
    {
        name: "Theofanis Sandoval",
        age: 20,
        major: "Communications Technology",
        coursesTaken: ["CT 101", "CT 201", "CT 137", "CT 160", "CT 360", "CT 370", "CT 381", "CT 385"],
        totalCredits: 95,
        enrolled: true
    },
    {
        name: "Wolf Shepard",
        age: 21,
        major: "Communications Technology",
        coursesTaken: ["CT 101", "CT 201", "CT 137", "CT 160", "CT 360"],
        totalCredits: 45,
        enrolled: false
    }
]

 

Leave a comment

Your email address will not be published. Required fields are marked *