# Help with Challenge(everything be true)

**URL:** <https://forum.freecodecamp.org/t/help-with-challenge-everything-be-true/169959>\
**Category:** General\
**Created:** [January 20, 2018, 10:15pm UTC](https://forum.freecodecamp.org/t/help-with-challenge-everything-be-true/169959 "2018-01-20T22:15:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![frothunda](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/frothunda/32/99658_2.png) [@frothunda](https://forum.freecodecamp.org/u/frothunda)\
**Post date:** [January 20, 2018, 10:15pm UTC](https://forum.freecodecamp.org/t/help-with-challenge-everything-be-true/169959/1 "2018-01-20T22:15:27Z")

</div>

Is there a reason why the code below is not working ?? I’ve tried every thing.

function truthCheck(collection, pre) {  
// Is everyone being true?  
for(var i=0;i\<collection.length;i++)  
{  
var obj = collection[i];  
for (var prop in obj)  
{  
if(prop == pre)  
{  
return true;  
}  
//return obj[prop];  
}  
}

return false;  
}

truthCheck([{“user”: “Tinky-Winky”, “sex”: “male”}, {“user”: “Dipsy”, “sex”: “male”}, {“user”: “Laa-Laa”, “sex”: “female”}, {“user”: “Po”, “sex”: “female”}], “sex”);

---

<div class="post-metadata">

**Author:** ![r1chard5mith](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/r1chard5mith/32/160542_2.png) [@r1chard5mith](https://forum.freecodecamp.org/u/r1chard5mith)\
**Post date:** [January 20, 2018, 11:45pm UTC](https://forum.freecodecamp.org/t/help-with-challenge-everything-be-true/169959/2 "2018-01-20T23:45:35Z")

</div>

It will return ‘true’ as soon as it finds one prop == pre, but you need to check them all.

---

<div class="post-metadata">

**Author:** ![frothunda](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/frothunda/32/99658_2.png) [@frothunda](https://forum.freecodecamp.org/u/frothunda)\
**Post date:** [January 21, 2018, 1:59pm UTC](https://forum.freecodecamp.org/t/help-with-challenge-everything-be-true/169959/3 "2018-01-21T13:59:09Z")

</div>

isn’t checking them all with the for loop?

---

<div class="post-metadata">

**Author:** ![perezvon](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/perezvon/32/112005_2.png) [@perezvon](https://forum.freecodecamp.org/u/perezvon)\
**Post date:** [January 21, 2018, 6:49pm UTC](https://forum.freecodecamp.org/t/help-with-challenge-everything-be-true/169959/4 "2018-01-21T18:49:17Z")

</div>

In your `for` loop, once it has found a match it `return`s that match, exiting the loop. You want to iterate over the entire loop, ensuring that each element is `true`, then `return` whether they all are or not only at the end.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 8:29pm UTC](https://forum.freecodecamp.org/t/help-with-challenge-everything-be-true/169959/5 "2021-01-17T20:29:44Z")

</div>

Closed on January 17, 2021, 8:29pm UTC


