what am i missing? it looks like its skipping right past all of this!
function lookUpProfile(name, prop){
// Only change code below this line
for (var x = 0; x < contacts.length; x++){
if (name === contacts[x].firstName) {
if (prop === contacts[x].prop) {
return contacts[x][prop];
} else {
return "No Such Property";
}
}
else {
return "No Such Contact";}
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
I didn’t know how to copy it over, so I did what I thought would work. I made it smaller because it looked to be taking over the entire page.
Explaining how to copy it over would have been more than enough.
That said, I don’t understand, why it’s is not checking the information being sent in. It should be responding with the proper output - but I’ve managed to cut it off somehow.
I don’t want to just copy it from the solution screen - that would defeat the purpose of learning.
@Marmiz has said where you can start looking for issues - try answering what they have said
Next time, if you have a question about a specific challenge as it relates to your written code for that challenge, just click the Ask for Help button located on the challenge. It will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.
As I have it, it looks to be skipping the function all together. I have the conditions met (I assume), but it is not responding.
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
// Only change code above this line
}
lookUpProfile("Akira", "likes");
Your browser information:
User Agent is: Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.2 Mobile/15E148 Safari/604.1.
sorry - my last message didnt have the code. I dont know how to tag you and copy my code into the response!
i have since played with it a bit, but i dont understand what im missing
.
without (prop === conntacts.prop) , its looking for “no such contact”. as soon as i add that line and the return - it just skips out completly.
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
for (var x = 0; x < contacts.length; x++){
if (name === contacts[x].firstName) {
if (prop === contacts[x].prop) {
return contacts[x][prop];}
}
else {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; rv:79.0) Gecko/20100101 Firefox/79.0.
so after fighting with this all night, for some reason the “||” is grey. I have noticed that if its grey, its 'invisible. The only other symbol i have on my computer is the ‘pause’ button. otherwise i think it would work
When I tried it (a few variations ago). It would not work. I don’t think it’s in there now, but I was wondering why it was not being “seen” by the computer