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.
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 truthy.property. The function would simply have a one line return statement.
I see. I misunderstood the way truthy.property 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.
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.