You can’t say that you didn’t find a person until you have searehd through the entire contacts array — which would mean the loop has ended and the firstName has not been found in the array. This: return "No such contact"; should be outside of the loop.
原文:http://www.cnblogs.com/Willy-Jane/p/6985617.html