Confused on the solutions for the code… i found did not use the code template… any help will be much appreciated
Your code so far
function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line
for (var i = 0; i <source.length; i++) {
if (collection.hasOwnProperty(source[i])) {
for (var j = 0; j < collection.length; j++) {
if ( collection[j] === source[i]) {
arr.push(collection[j]);
console.log(arr);
}
}
}
}
// Only change code above this line
return arr;
}
whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/wherefore-art-thou/