Tell us what’s happening:
Hi,
My code is able to pass most of the test cases except for two of them. However for the first test case the result is quite strange as it returns a string that spells “[object Object],[object Object]”. Any help with this would be greatly appreaciated, thanks!
Your code so far
function whatIsInAName(collection, source) {
// What's in a name?
var arr = [...collection];
// Only change code below this line
for (let item in source){
for(let i=0;i<collection.length;i++){
if (collection[i][item]!== source[item]){
collection.splice(i,1);
}
}
}
// Only change code above this line
return collection;
}
let name=whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
for (let i=0;i<name.length;i++){
for(let item in name[i]){
console.log(name[i][item]);
}
}
Your browser information:
User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/wherefore-art-thou/