Good evening all…
So I had a small break from the lessons due to some RL issues… and trying to get my head back in the in the game for the last few challenges of this part of the certification…
Here is where I am. Going through this challenge it will require finding the "key: being present in the search to be true… but otherwise it will need to be false…
Here is where I am with the code. :
function truthCheck(collection, pre) {
// Is everyone being true?
let result;
for (let i in collection) {
for(let z=0,z<= collection.length,z++){
if (collection[i].hasOwnProperty(pre)) {
return true;
} else {
if (!collection[i].hasOwnProperty(pre)) return false;
break;
}
}
}
truthCheck(
[
{ user: "Tinky-Winky", sex: "male" },
{ user: "Dipsy", sex: "male" },
{ user: "Laa-Laa", sex: "female" },
{ user: "Po", sex: "female" }
],
"sex"
);
The logic requires that once you hit a false value it can end… I am pretty sure this needs a “for loop” for a counter… in order to keep tabs on if the pariticular object it is looking at is the last one in case they are all true…
I would welcome some direction there…
Thank you in advance !