Profile Lookup challenge can someone please help me

Profile Lookup challenge can someone please help me
0.0 0


Hi guys,
So I wrote this code but I can’t seem to figure out what’s wrong with it. Any kind of help would be appreciated.

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(firstName, prop){
// Only change code below this line
var answer = "";
  switch(firstName, prop){
    case "Kristian", "lastName":
      answer = "Vos";
    case "Sherlock", "likes":
      answer = ["Intriguing Cases", "Violin"];
    case "Harry", "likes":    // returns ["Intriguing Cases", "Violin"] instead of ["Hogwarts", "Magic", "Hagrid"]
      answer = ["Hogwarts", "Magic", "Hagrid"];
    case "Bob", "number":
      answer = "No such contact";
    case "Akira", "address":
      answer = "No such property";
  return answer;
// Only change code above this line

// Change these values to test your function
lookUpProfile("Bob", "number");


Link to challenge:

You may be able to use this code to pass the tests, but it’s not a good way to solve this challenge with a switch statement because it is not robust enough to pass additional tests because the answers have been hardcoded. For every additional test I could make, the code above would need another case to pass the tests.

Let’s take a step back and re-read what the challenge wants and break it down:

  1. we have an array of objects called contacts (this is not referenced at all by your code- this is something we can and should use to check if names and properties are valid)
  2. we want to check if the first name is a valid first name in the array of objects
  3. we want to check if that particular first name has an additional property

So the first question would be: How would we go about checking each object in the array?