Profile lookup. Want to know whether something in my code could be used to start again

Tell us what’s happening:
I know my solution to this challenge is very different to the solutions given by fCC.
I’d like to know whether there’s something of value in it. The if statement seemed to work fine. I’d rather do it this way, for it’s the way I could do and understand.
I still don’t know why the error is in the return statement if the rest is fine.

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" || "lastName"); 
if (prop == "number" || "likes") {
    return ["value"];
}
}
for ( ; prop != ["number" || "likes"] ; ) {
return "No such property";
} for ( ; contact != ["firstName"] || ["lastName"] ; ) {
}
return "No such contact";

// Only change code above this line


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/85.0.4183.121 Safari/537.36.

Challenge: Profile Lookup

Link to the challenge:

The for loop is not included in the function lookup Profile.

1 Like

@auvx92a7 That was OK. The second return is not working though. Some ideas?
Thank you so much.

The second return is outside of {}.

Sorry I forgot to write the code.

if (name == "firstName" || "lastName"); 
if (prop == "number" || "likes") {
    return ["value"]; }
{

for ( ; prop != ["number" || "likes"] ; ) {
return "No such property";
} for ( ; contact != ["firstName"] || ["lastName"] ; ) {

return "No such contact";
}

@auvx92a7

if (name == "firstName" || "lastName");
if (prop == "number" || "likes") {
return ["value"] 
}

for ( ; prop != ["number" || "likes"] ; ) {
return "No such property";
} for ( ; contact != ["firstName"] || ["lastName"] ; ) {
}
return "No such contact";
}

It still keeps giving me syntax error, I know it must be a dumb error please help me with this.

Why are you using for loops like this? Don’t do that!

How do you intend this code to function? I’m honestly confused and I find that trying to make a sentence to describe what each line does helps in cases like this.

1 Like

You mean because of the extra semicolons or the whole loop?

Empty parts of a for loop head means that you should not be using a for loop.

1 Like

Thanks I’ll take care of that. I had used do while I should have stuck to that.

Are you new to JavaScript? Almost none of this is valid JavaScript code, so I wonder if you are mixing it up with another language.

2 Likes

I’m sorry. I have a psychiatric treatment so some things do not stick. I’m at more or less 90 percent of the curriculum of Basic JavaScript I think I should know better than use certain code. I studied a bit of Python but I don’t think that’s the problem.
It’s hard for me to land the more basic concepts. It sounds like an excuse, but it’s like that.

I think that you might want to repeat some of the fundamentals. Give it as much time and repetition as you need to feel comfortable with it. Right now the only correct lines are

return "No such property";

and

return "No such contact";
1 Like

It’s funny and sad because those are the only lines that seem to mess up the console.

@ArielLeslie thank you. I try really hard, believe me. But you’re right.

You have syntax issues hiding logic issues.

I’d focus on the lessons about strict comparisons, if statements, for loops, accessing object properties with bracket notation, and accessing array entries.

1 Like

@JeremyLT Thank you, I’ll do that. Do you think I will make it?

Anyone can code so long as they keep at it and work hard.

1 Like

Thank you. I work mostly at night because in the day I have to take care of my sick mum. So it’s hard some times to dedicate all the time and dedication I’d like to and is needed.
But I’m not going to surrender. Thank you for your words.

don’t be afraid to have two windows open side by side, one with current challenge and one with previous ones/documentation

also, once you do not have syntax errors, you could use a tool called pythontutor to see your code executed (it works for many languages, not just python)

1 Like