Profile Lookup - Get undefined value

Tell us what’s happening:
Hello guys
Frist im sorry for my bad english. but i will like to know
why i get undefined value from this line

var secName = contacts[i];
		return console.log(secName.fristName);

Thanks for help :slight_smile:
Your code so far


//Setup
//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++)
    {
        var secName = contacts[i][name];
		return console.log(secName.fristName);
        if(secName.firstName == name)
        {
            return secName[prop];
        }
        else
        {
            return "No such property";
        }
    }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/profile-lookup

console.log() print something to the console and returns undefined as a value. Don’t put it in a return statement

1 Like
return console.log(secName.fristName);

// should be
console.log(secName.firstName);

as the above reply stated, you should just console.log instead of returning.
also it’s probably showing up as undefined because of the typo “fristName”

1 Like

Oh i see, was my bad because i didn’t pay attention and didn’t read more about console.log ,thanks you for help :slight_smile:

yes is still show undefined but now i know. why didn’t work :slight_smile:
thanks you for help :slight_smile: