How do I write this function with function declaration
function sortAge
and not expression like
let sortAge = students.sort((a,b) =>a.age - b.age);
You need to add a students argument for the sortAge array function
const sortAge = students => students.sort((a, b) => a.age - b.age);
Put the expression inside the function definition.
function sortAge(students) {
return students.sort((a,b) =>a.age - b.age);
}