Tell us what’s happening:
I’m having trouble passing one of the test cases on this challenge. Here is the test case:
truthCheck([{name: "freeCodeCamp", users: [{name: "Quincy"}, {name: "Naomi"}]}, {name: "Code Radio", users: [{name: "Camperbot"}]}, {name: "", users: []}], "users")
should return true
.
What’s confusing me is that as you can see near the top of my code, the value of collection[2][‘users’] is , but if I enter (collection[2][‘users’] == ) I receive a value of false, and only get true when I enter (collection[2][‘users’] == ‘’).
I’m already checking in my code that any collection[collect][pre]= ‘’ will return false so I don’t know why this isn’t working, but I suspect is has something to do with the (seemingly contradictory) behavior outlined above.
**Your code so far**
function truthCheck(collection, pre) {
console.log(collection[2]['users'])
console.log(collection[2]['users'] == '')
for (let collect in collection){
if (collection[collect][pre] == false || collection[collect][pre] == '' || (typeof collection[collect][pre] == 'number' && isNaN(collection[collect][pre]) == true) || collection[collect].hasOwnProperty(pre) == false || collection[collect][pre] == null){
return false;
} else {
}
} return true;
}
console.log(truthCheck([{name: "freeCodeCamp", users: [{name: "Quincy"}, {name: "Naomi"}]}, {name: "Code Radio", users: [{name: "Camperbot"}]}, {name: "", users: []}], "users"));
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Safari/605.1.15
Challenge: Everything Be True
Link to the challenge: