Profile Lookup code test

Tell us what’s happening:

**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
if (name == "firstName" && prop !== null) {
return contacts[prop].value;
} else if (name !== "firstName" || "lastName"){
return "No such contact";
} else if (prop !== "number" || "likes") {
return "No such property";
// Only change code above this line

lookUpProfile("Akira", "likes");

Hi, someone could help me with this test?

**Your browser information:**

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

Challenge: Profile Lookup

Link to the challenge:

This is the wrong way to check if a value matches one of two options. Each side of the || needs to be a separate conditional test. Right now, you are checking if the string “lastName” is truthy, which it is.

Your code has a return statement for each of the possible logical branches. This means that your function will return and no further checks will be done after the first iteration of your loop.

I don’t understand this check. You seem to be attempting to hard code some part of the answer. You shouldn’t need to check this.

you may want to check again your understanding of the challenge, one of these is always true the other always false

1 Like

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