Remember, this is 0-based counting, so JavaScript starts with 0. To follow along with how this function does its counting, here's a complete breakdown: #0 (P) = no match; #1 (l) = no match; #2 (e) = no match; #3 (a) = no match; #4 (s) = no match; #5 (e) = no match; #6 ( ) = no match; #7 (l) = maybe match; #8 (o) = maybe match; #9 (c) = maybe match; #10 (a) = maybe match; #11 (t) = maybe match; #12 (e) = It's a match, return the position of the first maybe match (7). Note: If the function cannot find the string, it will return a value of -1.
A second parameter is acceptable as the starting position for the search.