Build a Book Organizer

I’ve read all the solutions and know it’s specifically the syntax of .sort() that needs work but I’ve tried all the permutations and can’t figure out why Test 9 doesn’t pass

let books = [
  {title:"A",
  authorName:"AAuthor",
  releaseYear:2005,
  },
  {title:"B",
  authorName:"BAuthor",
  releaseYear:2001,
  },
  {title:"C",
  authorName:"CAuthor",
  releaseYear:1940,
  },  
];

function sortByYear(book1, book2) {
  
  if (book1.releaseYear > book2.releaseYear) {
    return 1;
  }
  else if (book1.releaseYear === book2.releaseYear) {
      return 0;
  }
  else {return -1;}
  };

let filteredBooks = books.filter((rel) => rel.releaseYear>1944).sort(sortByYear);
  
console.log(filteredBooks);

Hi @larryyap

Try not to chain the filter and sort methods like so:

js
const filteredArray = array.filter(cb);
filteredArray.sort(cb);

Solved! But what’s the problem with chaining them?

the tests are not written to accept that