So I have an array which looks like the one displayed below:
const newTeachers = [
{ firstName: "Steve", subjects: ["English", "Maths", "History"] },
{ firstName: "Celia", subjects: ["Maths", "Science"] },
];
I want to create a function which takes in 2 parameters 1 being the array and 2nd being the filter string value.
function fliterSubject(teachers, subject) {
}
I have looked into the inbuilt way which is to implement this line of code:
return newCandidates.filter(teacher=> teacher.subjects.includes(subject));
However I want to understand how I can filter it manually instead of using the inbuilt filter function.
forloop and if currently iterated element matches or unmatches the condition push it to new array or not.