# Am I on the right track to solving the Wherefore Art Thou algorithm challenge?

Am I on the right track to solving the Wherefore Art Thou algorithm challenge?
0

#1

I realize that right now this code doesn’t work. I’ve spent awhile on this and feel pretty lost…

``````function whatIsInAName(collection, source) {
for(i = 0; i < collection.length; i++) {
if(Object.keys(collection[i]) && Object.values(collection[i]) === Object.values(source)) {
return collection[i];
}
}
}

whatIsInAName(

[{ first: "Romeo", last: "Montague" },
{ first: "Mercutio", last: null },
{ first: "Tybalt", last: "Capulet" }],

{ last: "Montague" });
``````

#2

Have you written out your algorithm (with no code or pseudo code) which would pass the challenge? If so, then post it here and we can tell if you are on the right track.

#3

I haven’t written code that has passed the challenge. This is what I have so far, and I want to know if it’s on the right track to passable code…

#4

Well, since you have not provided any written algorithm, all I can tell you is that your current solution is not on the right track, because your if statement is going to evaluate to false every time, because of:

``````Object.values(collection[i]) === Object.values(source)
``````

What exactly are you trying to accomplish with the following if statement? Better yet, what do you think it is checking in the if condition?

``````	if(Object.keys(collection[i]) && Object.values(collection[i]) === Object.values(source)) {
return collection[i];
}
``````