1. When utilizing the findUnsubmitted function with an array of submission objects, a specified date, and student names array, the function returns the names of students who have not completed any quiz on that particular date.
- If the findUnsubmitted feature does not detect any student names, it will return an empty array.
Upon console.log of the findUnsubmitted function, only [ 'Kevin', 'Nivek', 'John' ] is being returned; however, in this scenario, only Kevin and John should be part of the result.
const submissions = [
{
quizName: "Quiz 1",
quizModule: "Math",
quizScore: 100,
studentId: 001,
studentName: "Kevin",
submissionDate: "March 24, 2022"
},
{
quizName: "Essay",
quizModule: "English",
quizScore: 0,
studentId: 023,
studentName: "Nivek",
submissionDate: "April 1, 2022"
},
{
quizName: "Quiz 2",
quizModule: "Science",
quizScore: 71.59485,
studentId:023,
studentName: "John",
submissionDate: "May 24, 2022"
}
]
const filterByDate = (specificDate, submission) => {
return submission.filter((sub) => sub.submissionDate === specificDate)
}
const findUnsubmitted = (specificDate, names, submission) => {
const date = filterByDate(specificDate, submission);
const unsubmitted = names;
for(let i = names.length - 1; i >=0; i--) {
const student = date[i];
if(student == names.studentName){
submissions.splice(i, 1);
}
return unsubmitted;
}
}
console.log(findUnsubmitted('April 1, 2022', ['Kevin', 'Nivek', 'John'], submissions));