Exam: Building Interactive Websites - Cannot read properties of undefined (reading 'toLowerCase') in CC editor but Dev Tools throws no errors

Hi, I’m working on part 2 of the Building Interactive Websites exam and when I test my code for the 2nd test case I get the following error: “Cannot read properties of undefined (reading ‘toLowerCase’)”. However, when I inspect in Dev Tools, no error is thrown.

const filterBooks = (searchStr, bookList) => {
  let results = [];
  const strLower = searchStr.toLowerCase();
  const arrBookList = flattenObjectValuesIntoArray(bookList);
  const listJoin = arrBookList.join('~').toLowerCase();
  console.log(listJoin);
  const lowerList = listJoin.split('~');
  results = lowerList.filter((book) => book.includes(strLower));
  return results;
};
//The log below returns the intended data in Dev Tools
console.log(filterBooks('fantasy', books));

I’m not looking for the answer since this is an exam, but before I spend even more time trying to fix this error, can someone just verify that it’s not a bug with CC’s editor?

1 Like