1.Given an array of submission objects, when I supply a date, an array of student names, and an array of submission objects to the findUnsubmitted function, I am returned an array of names of students that haven't completed any quiz on that date.
- Given the the findUnsubmitted feature doesn't find any student names, I am returned an empty array.
When I console.log my findUnsubmitted function, I am just returned: [ 'Kevin', 'Nivek', 'John' ] ... when in this case, I should only be returned Kevin and John in the array...
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 = (particularDate, submission) => {
return submission.filter((sub) => sub.submissionDate === particularDate)
}
const findUnsubmitted = (particularDate, names, submission) => {
const date = filterByDate(particularDate, 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));
If you just want to return an array of names of students that haven't completed any quizzes on that date. Don't make it complicated
In function:
findUnsubmitteddon't need usingnamesvariable.Change code in function
filterByDatelike:and function
findUnsubmitted:Hope that it helps you.