Profile lookup challenge help needed

Tell us what’s happening:
I have been revisiting challenges to clear up my concept. Where have I made a mistake?

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++){
return contact[i][prop];
else {
return "No such property" 
return "No such contact"
// Only change code above this line

lookUpProfile("Akira", "likes");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66.

Challenge: Profile Lookup

Link to the challenge:

I believe that your condition for your for loop is backwards. The code runs so long as the condition is true, and your condition will never be true.

By the way, I added some formatting to your code to make it more human-readable.

1 Like
for(var i=0; i<contacts.length; i++){

Here the less than symbol must be used.
And another problem is that you have missed an ‘s’ in contacts here.

             return contacts[i][prop];
1 Like

Thanks @JeremyLT and @krishnasai3cks