Basic JavaScript: Profile Lookup Stuck

What’s wrong with my code?

function lookUpProfile(name, prop){

for (var x = 0; x <contacts.length; x++){

    if (contacts[x].firstName == name && contacts[x].hasOwnProperty(prop)){

        return contacts[x][prop];

    }   else {

        return "No such property";



return "No such contact";

// Only change code below this line

// Only change code above this line


what do the failing tests say?

// running tests

"Kristian", "lastName"

should return

"Sherlock", "likes"

should return

["Intriguing Cases", "Violin"]

should return an array

"Bob", "number"

should return “No such contact”

"Bob", "potato"

should return “No such contact” // tests completed

why don’t you try to see what your function actually returns?
try with for example adding the following on the last of the editor: console.log(lookUpProfile("Kristian", "lastName"))

your command returned “no such property”

For context, it works if i do it like this

awesome, you managed it! happy coding!