Everything Be True question

Tell us what’s happening:
On the last if statement, when I change the conditions around(falseCount===0 and falseCount>0), the completed Ii had become grey and the other one are ticked. Why is that, if the statement still covers both conditions?

Your code so far


function truthCheck(collection, pre) {
 for (let i = 0; i < collection.length; i++) {
   for (let key in collection[i]) {
   var falseCount=0;
     if (collection[i].hasOwnProperty(key)) {
       console.log("checking " + JSON.stringify(collection[i]));
       if (collection[i][pre]) {
         console.log("this is true!");
       } else {
         console.log("this is false!");
         falseCount++;
         console.log("falseCount is " + falseCount);
        }
      }
      
      }
      if (falseCount=0) {
        return true;
    }   else {
      return false;
    }
  }
}

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

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/everything-be-true

Nevermind, I figured out that specific statement I believe. I moved the if statement until after the for loop. Now, I think that if falseCount is anything other than zero, it should return false. But from the console, I can’t really see why e few of them return the wrong thing. They also appear twice for some reason. Here is my code:

function truthCheck(collection, pre) {
 for (let i = 0; i < collection.length; i++) {
   for (let key in collection[i]) {
   var falseCount=0;
     if (collection[i].hasOwnProperty(key)) {
       console.log("checking " + JSON.stringify(collection[i]));
       if (collection[i][pre]) {
         console.log("this is true!");
       } else {
         console.log("this is false!");
         falseCount++;
         console.log("falseCount is " + falseCount);
        } else if (!collection[i].hasOwnProperty(pre)) {
          return false;
        }
      }
      
      }
     
    }
    if (falseCount===0) {
        return true;
    }   else {
      return false;
  }
  }
   


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