Well, this is not just the Queen song, it’s my current state of mind.
I am working my way through the JavaScript Basics and I am having a hard time near the end.
This is my solution to the “Profile Lookup” problem:
/*****************************************
function lookUpProfile(name, prop){
for ( var i = 0; i < contacts.length; i++) {
if (name === contacts[i].firstName) {
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
} else return "No such property";
} else return "No such contact";
}
******************************************/
And this is the solution on the FFC website:
/*******************************************
for (var x = 0; x < contacts.length; x++){
if (contacts[x].firstName === name) {
if (contacts[x].hasOwnProperty(prop)) {
return contacts[x][prop];
} else {
return "No such property";
}
}
}
return "No such contact";
******************************************/
Theirs is working, mine doesn’t. It passes the last conditions, the ones with No such contact / property but not the first three ones, which input the data to be returned. And I spent an hour already trying to figure it out and it is just so frustrating, I am literally crying.
Thank you.