Need assistance! Trying to figure out how to create a function that locates books with an author name containing less than 4 characters.
const books = [
{
"id": "a5b16ad1bb2e96b8c649da7150ad5726",
"title": "Mon Oct 17 2022 21:32:42 GMT-0700 (Pacific Daylight Time)",
"author": "Ana"
},
{
"id": "221517d1a0948a2faa56a824803aa60e",
"title": "bjlci",
"author": "Lea Ann"
},
{
"id": "286332e30d3962f5de20c2cf8b673482",
"title": "Mon Oct 24 2022 00:38:43 GMT-0700 (Pacific Daylight Time)",
"author": "Ana Lee"
},
{
"id": "bd78bed71d601bdd19c76c8309287894",
"title": "Mon Oct 17 2022 21:32:42 GMT-0700 (Pacific Daylight Time)",
"author": "Lee"
}
]
In progress: getting error message TypeError: Cannot read properties of undefined (reading 'length')
function shortNameAuthors(books){
for (let i = 0; i < books.length; i++){
if (books["author"].length <4){
console.log(books[i]);
}
}
}
console.log (shortNameAuthors(books))