Basic JavaScript - Profile Lookup - t-W6uew7Rm-a321Tw7q2-

Tell us what’s happening:
Describe your issue in detail here.
Hi,
I guess I have written the code correctly. But don’t know why the run tests showing error for some cases. Can any one help me…

   **Your code so far**
// Setup
const 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) {

for (let i = 0; i < contacts.length; i++) {
 if(contacts[i].firstName === name) {
   if(contacts[i].hasOwnProperty(prop)) {
    return contacts[i][prop];  
    }else{ 
       return "No such property";
       }
     }
   }
return "No such Contacts";
}
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/103.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Profile Lookup

Link to the challenge:

Thank you Randell. I am spending hours for this small mistake.
Thank you so much.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.