Tell us what’s happening:
Can someone please tell me why my editor is displaying false when i’m testing if the object has this particular property?
Your code so far
let newArray = [];
let finalArray = [];
for (const key in source) {
// console.log(`${key}: ${source[key]}`);
newArray[key] = source[key]
}
// console.log(source)
// console.log(collection)
console.log(Object.keys(collection[2]))
console.log(Object.keys(newArray))
console.log(collection[2].hasOwnProperty('first','last'))
console.log(collection[2].hasOwnProperty(Object.keys(newArray)))
// console.log(source.hasOwnProperty('first'))
return finalArray = [];
}
whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }],{first: 'Tybalt', last: "Capulet" }); /* should return [{ first: "Tybalt", last: "Capulet" }].
and in my console I get
[‘first’, ‘last’ ]
[ ‘first’, ‘last’ ]
true
false
Challenge: Wherefore art thou
Link to the challenge: