I don't see where the quadratic time complexity comes from. There's a single loop performing n operations in total, ie. O(n).
In practice, memory allocators tend to double the size of an allocation like this, which is still quadratic.
In practice, JS runtimes also tend to use data structures like Ropes for strings to handle this sort of issue. That brings it down to linear time in practice (I think?)
That linear-time operation is then additionally repeated `len` times