I am trying to find a certain string within an array.
This is my code so far:
function getUserName(arrayName){
for (counter = 0 ; counter < arrayName.length ; counter++){
check = arrayName[counter].search("Jon");
if (check != -1){
result = arrayName[counter];
}
break;
}
}
The problem that I am running into is that if there is a name above Jon
in the array (e.g Jon_111)
the result would be Jon_111
and not Jon
What do I use to tell it to only find and return if it is exactly Jon
.