Everything Be True - stuck :(

Everything Be True - stuck :(
0

#1

Tell us what’s happening:
Hello everyone,
I’m stuck at this exercise, i have the code below and I dont understand why it does not validate everywhere.

Actually i dont understand some of the requirements like this one:

truthCheck([{“single”: “”}, {“single”: “double”}], “single”) should return false - WHY? ‘single’ exists in every element of the collection …

Thank you in advance for your input.

Your code so far

  // Is everyone being true?
  var bool = false
  Object.keys(collection).forEach(function(key) {
      if (collection[key].hasOwnProperty(pre)) {
        console.log(collection[key].hasOwnProperty(pre))
        bool += true
      } else {
        bool += false
      }
  })
  if (bool < collection.length) {
      return false
  } else {
      return true
  }
}```
**Your browser information:**

Your Browser User Agent is: ```Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36```.

**Link to the challenge:**
https://www.freecodecamp.org/challenges/everything-be-true

#2

You are not trying to validate the property exists in each object, you are trying to validate the value of the property is “truthy” (evaluates to true). In the following object in the array:

{"single": ""}

The value of “single” is a blank string which is a “Falsy” value. I would recommend reviewing the Falsy Bouncer Challenge to better understand what you need to do for this current challenge.


#3

Thank you so much, yes I eventually figured it out.

Much appreciated!