Problem
function addAndSort(array, element) {
  return array.push(element).sort();
}
Solution

When you call array.push, it doesn’t return the updated array, but rather the updated length of the array with the new item. That means you can’t chain the .sort() call to the end, since the result of .push is a number.

There are two ways to fix this. One option is to call array.sort() after the .push call.

function addAndSort(array, element) {
  array.push(element)
  return array.sort();
}

The second option appends the item to a new array with array.concat() and then sorts the new array.

function addAndSort(array, element) {
  return array.concat(element).sort();
}