I am attempting to find out which teacher is responsible for a particular student based on the classroom they are in. Each teacher corresponds to a specific set of classrooms.
let teachers = ["Arrington", "Kincart", "Alberts", "Pickett"]
let rooms = [
["Andy", "Rodolfo", "Lynn", "Talia"],
["Al", "Ross", "Jorge", "Dante"],
["Nick", "Kim", "Jasmine", "Dorothy"],
["Adam", "Grayson", "Aliyah", "Alexa"]
]
let findTeacher = (student) => {
return rooms.findIndex(row => row.indexOf(student) !== -1)
}
console.log(`The teacher who manages Jorge is ${findTeacher("Jorge")}.`)
console.log(`The teacher who guides Alexa is ${findTeacher("Alexa")}.`)
The current result shows:
The teacher who has Jorge is 1.
The teacher who has Alexa is 3.
I realize that I'm close, but I need assistance in outputting the actual name of the teacher instead of just their index number.