Your code only ever checks the first member of contacts. When i is 0, it either returns a property value, returns “No such property” or returns “No such contact”.
@anasansari157 - I updated your code a bit and ran the test which fails for you.
Also wrote an alternate lookup function (alternateLookUpProfile) - less code, more readable.
It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.
If you want to compare your solution to others, use the Get a hint button on the challenge and there are alternative solutions you can compare yours to. Also, you can probably search older posts using the forum search feature or google the challenge name and find more there.
We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.
Ok. I have understood now that the for loop is running for once because of the last else statement. That is why my loop breaks if it doesn’t find the same firstName.
First solution comes to my mind is to remove the last statement that returns. But, ATQ, I need that too.
How to stop my loop it’s found the same firstName and tell it to continue if it hasn’t found ?
please don’t
instead be happy you were able to come up with the solution yourself!
it will become easier and easier (with some roadblocks, which instead become bigger as you go forward)