Tell us what’s happening:
So this is my code so far, but I cant seem to get it to work with the other required properties and values.
I thought I could just add another 'lookUpProfile ’ call, but it didnt make a difference.
I am looking for any help to this issue.
Many thanks
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].firstName === name){
return contacts[i][prop] || "no such property";
}
}
return "no such contact";
// Only change code above this line
}
lookUpProfile("Bob", "number");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0.
Challenge: Profile Lookup
Link to the challenge: