Hi @Alexoid, welcome on the forum.
When you use the return statement, the execution of the function stops and the flow goes back to whatever called it.
In your case, the return str; in the for loop makes the execution stop at the first iteration, when the counter is still at one.
The return should go after you have done all the iterations of the for loop, returning the result string made by the repetition not the initial string.