Profile Lookup : ERROR TEST CASE

Profile Lookup : ERROR TEST CASE
0

#1

Tell us what’s happening:

the fifth test case “Bob”, “potato” is error ? it should be “No such property” .

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

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


#2

It’s not an error. It should return no such contact.

Bob is not in the list of contacts.


#3

hi there, thank you for your support !