Hm, I think you may have misunderstood what I was saying.

I whipped this up: http://jsfiddle.net/NtRU9/ that seems like a slightly simpler way to handle it, since we're just passing str.length into the function. Is that a reasonable approach?

Sorry for taking a few days to get back to you.