How to Count Objects in an Array

PHOTO EMBED

Mon Mar 28 2022 08:20:17 GMT+0000 (Coordinated Universal Time)

Saved by @jalimpia #javascript

const storage = [
  { data: '1', status: '0' },
  { data: '2', status: '0' },
  { data: '3', status: '0' },
  { data: '4', status: '0' },
  { data: '5', status: '0' },
  { data: '6', status: '0' },
  { data: '7', status: '1' },
];

const count = storage.filter(function(item){
  if (item.status === 0) {
    return true;
  } else {
    return false;
  }
}).length; // 6
content_copyCOPY

https://www.freecodecamp.org/news/how-to-count-objects-in-an-array/