Profile Lookup I'm stuck

Profile Lookup I'm stuck
0.0 0


Tell us what’s happening:

Your code so far

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(name === contacts[i]["firstName"]){
            return contacts[i][prop];
        return "No such property";}
    return "No such contact";

// Only change code above this line

// Change these values to test your function
lookUpProfile("Akira", "likes");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:

// running test
"Kristian", "lastName" should return "Vos"
"Sherlock", "likes" should return ["Intriguing Cases", "Violin"]
"Harry","likes" should return an array
// tests completed

I don’t understand why those three code won’t run. I think i’ve done it perfectly,
am i missing something like a syntax error??
Also, I’m a bit confused about if else statement too.


Suppose you’ve entered lookUpProfile(“Harry”,“number”);
It would fail and return No such contact and always will unless the input satisfies for contacts[1][“firstName”]
You’ve included that return statement inside your for loop I’d suggest fit in that return statement in seperate for loop