I have an object that looks like this:
let res = [{
stop: "stop1",
students: [
"Maria",
"Mario"
]},
{stop: "stop2",
students: [
"Giovanni",
"Giacomo"
]
}];
and a function that checks if a student is already present at a given bus stop:
checkStudent(stopName: string, studentName: string): boolean {
// iterate over res and check if students is present
}
what I've done so far is iterate over res object, check every stopName until one of these match with the 'stopName' parameter and then iterate over students array to check if student is present. I'd like to know if there is a better way to do this. Can I directly access the right students array given the stop name? I'm using typescript
studentsandstop?