Search by last name works now.  Just changed the for loop j<
allcontacts.length to be j< counter and that fixed the problem.