Build a Book Organizer - Build a Book Organizer

Tell us what’s happening:

I’m stuck on test 9. I believe my console log is showing that the array is being sorted correctly. Is it the way I have it set up??

Your code so far

const books = [
  {
    title: "Book1",
    authorName: "author1",
    releaseYear: 2023
  },

  {
    title: "Book4",
    authorName: "author1",
    releaseYear: 2022
  },
  
  {
    title: "Book2",
    authorName: "author2",
    releaseYear: 2025
  },

  {
    title: "Book3",
    authorName: "author3",
    releaseYear: 2024
  }
];

function sortByYear(book1, book2) {
  
  const book1ReleaseYear = book1.releaseYear;
  const book2ReleaseYear = book2.releaseYear;
  
  if (book1ReleaseYear < book2ReleaseYear) {
    return -1
  }
  
  if (book1ReleaseYear > book2ReleaseYear) {
    return 1
  }

  if (book1ReleaseYear === book2ReleaseYear) {
    return 0
  }
};

const filteredBooks = books
.filter(book => book.releaseYear > 2023)
.sort((a, b) => sortByYear(a, b));



console.log(filteredBooks);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36

Challenge Information:

Build a Book Organizer - Build a Book Organizer

https://www.freecodecamp.org/learn/full-stack-developer/lab-book-organizer/build-a-book-organizer

9. You should call the sort higher order function by passing the sortByYear callback function on the filteredBooks array.

This is the test that’s failing.. am I not doing that on line 47?

Okay I figured it out! Man, I was close. Any more info might be too close to solution.. thanks if anyone was taking a look.

that part has frustrated me for over 30 min and the answer was soo simple.. besides the pain of not putting a semi colon in a code and trying to figure the error in two days this is the next best worse pain :sob: