>> SPEAKER 1: It turns out there's still an opportunity to improve this
program's design.
Notice in my for loop that on each iteration, I'm checking that i is less
than the string length of s.
But the string length of s is always going to be the same, because s itself
is not changing.
And yet, every time through this loop I'm checking the string length of s,
the string length of s, the string length of s, which is just silly.
Because surely it must take some amount of time to figure out a
string's length.
And I'm wasting that time by asking the same question again and again.
>> Well, it turns out we can improve this by declaring, say, a second variable
inside of my for loop.
Let's call it n-- and separate it from i, with a comma like this--
and set n equal to the string length of s.
Semicolon.
And now, let's change my condition to not compare i against the string
length of s per se, but instead against n.
In this way, we initialize n to the string length of s.
But on each iteration of my loop, I'll instead be checking i against n.