This is an example of recursion. It can be very confusing at first, but the way to do it is to take a set of small number (1,2,3) and follow through the execution.
So, if num is one, the return value is just str. Expected.
Now, if it is 2, the return value is str + the same function called again. So if we set up a stack of return functions:
return str + repeatStringNumTimes(str, 1) = return str + (return str),
and the point is that the second return will be evaluated before the first one.