Hello all,
Can someone please assist me in trying to solve this challenge? From what I’m seeing, the code block is fulfilling the set conditions, which is obviously not the case. I’m more looking for an explanation as to what my code is doing wrong than an actual solution, because where’s the fun in that?
function truthCheck(collection, pre) {
let result;
for(let i in collection) {
if(collection[i].hasOwnProperty(pre)) {
if(collection[i].pre) {
result = true;
} else {
result = false;
}
}
}
return result;
}
truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");