Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

281
Views
How do I check if object property is true/false and output based on true/false

I've been trying to figure this one out - if someone has some pointers I would appriciate it. Basically I got an object which has 3 properties, I need to check if one of those properties is true or false, and return based true/false. So far, made this code but as I understand it doesn't recognize 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);

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You take not really a book, like

const book = arg[i], // iterate arg

You could iterate the books and destructure a single entry into the parts and use this parts.

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);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!