Working on this algorithm now: https://www.freecodecamp.org/challenges/wherefore-art-thou
The code below is only pushing an object into the array a single time. For some reason, it won’t push a second object into it, even if the condition is true. I’m not sure what I’m missing, but I believe I just made my for loop incorrectly. I’m pretty open to being wrong. I have no idea what I’m doing in general.
function whatIsInAName(collection, source) {
var arr = [];
var sourceProperty = Object.keys(source);
for (i=0; i<collection.length; i++)
{
if (collection[i][sourceProperty] === source[sourceProperty]) {
arr.push(collection[i]);
return arr;
}
}
}