The last space string you’re adding at the end of the chain on every iteration is the culprit. Since your output ends up like this "I'm A Little Tea Pot ", instead of "I'm A Little Tea Pot". It would be alright if It wasn’t because of the “space” character added at the end of the last string.
I suggest to initialize collection as an empty array, then push the Capitapized string in collection on every iteration. Then afterwards, use collection.join(’ ') to transform the array into a string and then return the result. You can also remove the trailing space with slice after the cycle, feel free to do and come up with whatever other solution.