He estado tratando de resolver esto, si alguien tiene algunos consejos, lo agradecería. Básicamente obtuve un objeto que tiene 3 propiedades, necesito verificar si una de esas propiedades es verdadera o falsa, y devolverla basada en verdadero/falso. Hasta ahora, hice este código pero, según tengo entendido, no reconoce object.properties..
const library = [ { title: "Bill Gates", author: "The Road Ahead", isRead: true }, { title: "Steve Jobs", author: "Walter Isaacson", isRead: true }, { title: "Mockingjay: The Final Book of The Hunger Games", author: "Suzanne Collins", isRead: false } ]; const showStatus = (arg) => { let book = arg; for(let i = 0;i < book.length; i++){ if(book.isRead === true){ console.log(`Already read ${book.title} by ${book.author}.`) } else { console.log(`You still need to read ${book.title} by ${book.author}`) } } }; showStatus(library);No tomas realmente un libro, como
const book = arg[i], // iterate argPuede iterar los libros y desestructurar una sola entrada en las partes y usar estas partes.
const library = [{ title: "Bill Gates", author: "The Road Ahead", isRead: true }, { title: "Steve Jobs", author: "Walter Isaacson", isRead: true }, { title: "Mockingjay: The Final Book of The Hunger Games", author: "Suzanne Collins", isRead: false } ]; const showStatus = (books) => { for (const { title, author, isRead } of books) { if (isRead) { console.log(`Already read ${title} by ${author}.`); } else { console.log(`You still need to read ${title} by ${author}`); } } }; showStatus(library);