What's wrong in Profile Lookup?

Tell us what’s happening:
I don’t understand what’s happening with my code. I’ve checked out several times and I still get errors.

The errors are these:

"Kristian", "lastName" should return "Vos"

"Sherlock", "likes" should return ["Intriguing Cases", "Violin"]

"Harry","likes" should return an array

Three of the six tasks assigned I’ve done well so far, but these above I don’t know what’s wrong.

Your code so far

// Setup
var contacts = [
    "firstName": "Akira",
    "lastName": "Laine",
    "number": "0543236543",
    "likes": ["Pizza", "Coding", "Brownie Points"]
    "firstName": "Harry",
    "lastName": "Potter",
    "number": "0994372684",
    "likes": ["Hogwarts", "Magic", "Hagrid"]
    "firstName": "Sherlock",
    "lastName": "Holmes",
    "number": "0487345643",
    "likes": ["Intriguing Cases", "Violin"]
    "firstName": "Kristian",
    "lastName": "Vos",
    "number": "unknown",
    "likes": ["JavaScript", "Gaming", "Foxes"]

function lookUpProfile(name, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i++){

    if(contacts[i].hasOwnProperty(prop) && contacts[i].firstname === name){
        return contacts[i].prop
    }else if(name != contacts[i].firstName){
        return "No such contact"
    }else if(contacts[i].hasOwnProperty(prop) == false){
        return "No such property"

// Only change code above this line

lookUpProfile("Akira", "likes");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0.

Challenge: Profile Lookup

Link to the challenge:

Hello and welcome to the FCC community~!

Take a look at your if and else if logics. Right now, the for loop checks the first contact, and if firstname matches name and contact has a prop, it returns that prop. Else, if that contact does not match name, it returns “No such contact”. Else, if that contact does not have a prop, it returns “No such property”.

Remember that the return statement ends a function. Your loop doesn’t get to check any contact after the first. :slight_smile: