const schoolObj = {
class10: { studentName: John, result: pass },
class11: { studentName: Alis, result: pass },
class12: { studentName: Nick, result: fail },
};
How to create list of studentName if result is pass. class10,11,12 all are dynamic values.I am stuck at how to access this dynamic value in iteration.
I want result like array of student = [John, Alis]
2
Answers
Filter the object values so that you only have the students that have passed left. Then map the student objects so that you get an array with their names.