Profile Lookup of Contacts not running

Tell us what’s happening:

Can someone help me figure out what’s wrong cause I can’t seem to figure it out

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 (name !== contacts[i].firstName) {
return "No such contact";
  } else if (contacts[i].hasOwnProperty(prop) === false) {
return "No such property";
  } else {
    return contacts[i][prop];
  }
}
// Only change code above this line
}

// Change these values to test your function
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/66.0.3359.181 Safari/537.36.

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

for (var i= 0; i < contacts.length ; i++) {
if (name !== contacts[i].firstName) {
return “No such contact”;

Watching these three lines: suppose name is not the first person in the array (maybe it’s the 2nd, 3rd, …): your loop won’t check further: name !== contacts[0].firstName results true so it return No such contacts^^
I didn’t tested it, is just a, idea^^

Hahahaha, I was writing ES6 code locally, even though I have completed this challenge i am lost in ES6

contacts.map(contact => {
        if((contact.firstName === name) && contact.hasOwnProperty(prop)) {
            return contact;
        } else if(!contact.hasOwnProperty(name)) {
            return "No such contact";
        } else if(!contact.hasOwnProperty(prop)) {
            return "No such property";
        }
    })