We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 4: Count Objects
Day 4: Count Objects
Sort by
recency
|
382 Discussions
|
Please Login in order to post a comment
function getCount(objects) { return objects.filter(obj => obj.x === obj.y).length; }
In JS
function getCount(objects) { let count = 0 const map = objects.map((item) => { if(item.x == item.y){ count +=1 } }) return count }
And just because we can, here is a version using reducer: