Profile lookup looping problem

now i see, so the loop should continue to the next element in the array after verifying that ‘Akira’ !== ‘Harry’ rather than returning ‘No such contact’. Is that it?

yes, as it is now your loop stops at first iteration

thank you for the help. Let me try rereading the for loop because i am still finding it a challenge to solve that problem.

hint: the logic doesn’t have to be all inside the loop

1 Like

Thank you for your patience. i have found the solution! The loop was being halted at at the first element because of the return statement. So i placed the return statement after the for loop block so that the computer can parse it after it has looped over all the elements in the array.
quick question (if i may), why wouldn’t the && operator be used in this case, or rather in what context does the operator apply?

thank you for the help. You have helped in making me understand how to divide my algorithms into smaller parts.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.