-
-
Save IrhaAli/b0dc7efd45751cd812b7e9f6d3abfc5c to your computer and use it in GitHub Desktop.
Given a list of instructors and courses they are teaching, returns the list of instructors teaching a given course.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const organizeInstructors = function(instructors) { | |
let orgIns = new Object(); | |
for (let i in instructors){ | |
if (orgIns.hasOwnProperty(instructors[i].course)){ | |
orgIns[instructors[i].course].push(instructors[i].name); | |
}else { | |
orgIns[instructors[i].course] = [instructors[i].name]; | |
} | |
} | |
return orgIns; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment