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
|
380 Discussions
|
Please Login in order to post a comment
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:
function getCount(objects) { let count=0; for (let o of objects){ if(o.x==o.y){ count++; } } return count; }
is this best practice?