I suggest to use an Array instead of a String for output: it's cheap to add elements in it, and it's still possible to make it a String by using `.join('')`.