Help with Everything Be True; Almost there

I’m using a for loop to iterate through the collection and using Object.entries to access each property in the collections Object.

I’m having trouble getting the every() function to evaluate if the collection is truthy/falsy. I can set it to check one or the other but not both. How do I get it to output successfully for either.
Link to challenge:

function truthCheck(collection, pre) {
  let arr = [];
  for (var i = 0; i < collection.length; i++ ) {
      arr.push( Object.entries(collection[i]) )    
  function istrue(currentValue) {
    return Boolean(currentValue);


 return arr.every(istrue);


Missing challenge instructions to be able to help (or your goal here anyway). What is the link to the challenge?

1 Like

You need to console.log(arr) after the for loop. I think you will be surprised when you look at the browser’s console. Your function will always return true which is the only reason you are passing 3 of the tests (which expect true to be returned).

You are pushing a two-dimensional array into arr in each iteration of the for loop. Arrays are truthy so you return true.

Thank you. I think I see what you mean. Object.entries remains a two-dimensional array, and is not pushed as a single itemized list, which is what I thought the for loop was going to do. I need to break it down further, and then iterate through each item and check if it is truthy/falsy.

thx. Just posted the URL.

Keep in mind that you need to make the the value of the property specified by the 2nd argument is truthy for all the objects in the collection, not all the properties’ values.

Hint: You can use the every method, but you do not need to create an extra array to use it on. Just use the collection array and make sure every object has a pre property which has The function would simply have a one line return statement.

This is my solution (with code blurred out).


1 Like

I see. I misunderstood the way worked. So there’s no need to check if it is or isn’t, explicitly, since it will evaluate to true/false either way on its own. I googled it and realize what you mean now. I used just the collection array and combined it with pre in the every function.

1 Like

Note: I’m just realizing that it was not about iterating through every key: value pair, but making sure that every object has a pre property that evaluates to true.