Profile Lookup - Need advice regarding the courses

Profile Lookup - Need advice regarding the courses
0

#1

Tell us what’s happening:
My code is working well but when i tried to check the answer of the website,i could’t understand anything ;clearly it’s html or css which i haven’t studied yet…i started with JS. Must i stop now and start learning the html and css course ? or can i finish the JS course then start the html and css courses ?..does this line of coding really solve the problem ? ( looks much more simple than my program)

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
var j=0;
for(var i=0;i<contacts.length;i++)
{
    if(contacts[i].firstName == name && contacts[i].hasOwnProperty(prop))
    {
        return contacts[i][prop];
    } 
}
for (var i=0;i<contacts.length;i++)
{
     if(contacts[i].firstName != name )
    {
       j+=1;   
    }
} 
if(j === 4)
{
    return "No such contact" ;
}
  return  "No such property" ;
    

// Only change code above this line
}

// Change these values to test your function
console.log(lookUpProfile("Kristian", "lastName"));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

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