Tell us what’s happening:
I don’t know what to do without looking at hints and solution. And I don’t want to use hints and solution. I want to complete this task on my own. The question is if amount of knowledge from previous tasks enough to complete this task without using external sources and hints, because when I’m brushing through previous task over and over nothing helpful comes to my head that my help me in finishing current one.
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
// Only change code above this line
}
// Change these values to test your function
lookUpProfile("Kristian", "lastName");
/* BACKUP COPY */
/*
function lookUpProfile(name, prop){
// Only change code below this line
var data;
for (var i = 0; i < contacts.lenght; i++) {
for (var j = 0; j < contacts[i].length; j++) {
if (name === "firstName" && prop === prop) {
data = prop;
return data;
} else if (name !== "firstName") {
data = "No such contact";
return data;
} else {
data = "No such property";
return data;
}
}
}
return data;
// Only change code above this line
}
*/
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/profile-lookup/