Created
September 4, 2021 05:53
-
-
Save madeleine68/7f5db6af6f39567223db01fd6e81598d to your computer and use it in GitHub Desktop.
This file contains hidden or 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) { | |
let sorted = instructors.sort(function(a, b) { | |
return b.name.length - a.name.length; | |
}); | |
return sorted[0]; | |
}; | |
console.log(instructorWithLongestName([ | |
{name: "Samuel", course: "iOS"}, | |
{name: "Jeremiah", course: "Web"}, | |
{name: "Ophilia", course: "Web"}, | |
{name: "Donald", course: "Web"} | |
])); | |
console.log(instructorWithLongestName([ | |
{name: "Matthew", course: "Web"}, | |
{name: "David", course: "iOS"}, | |
{name: "Domascus", course: "Web"} | |
])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment