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
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