-
-
Save IrhaAli/4014682a6a599e459b514fb72645d929 to your computer and use it in GitHub Desktop.
Returns the information on the instructor with the longest name.
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 instructorWithLongestName = function(instructors) { | |
//tracks the longest name instructor | |
let longestNameIndex = 0; | |
//goes through all the instructors | |
for (let i = 0; i < instructors.length; i++){ | |
if (instructors[i].name.length > instructors[longestNameIndex].name.length){ | |
longestNameIndex = i; | |
} | |
} | |
return instructors[longestNameIndex]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment