var trainers = ['ash', 'misty', 'brock'];
/*
you can specify an anonymous function as a parameter to the text() method
this is specifically useful when you're trying to assign text to each element in a list or any element which you can iterate over.
In the example below were just returning the trainer on the current index(from 0 to 2)
This effectively changes the text of all 3 list items depending on the current item in the array.
*/
$('ul:first li').text(function(index, text){
return trainers[index];
});
<ul>
<li>abc</li>
<li>def</li>
<li>ghi</li>
</ul>