So, my question has been asked by someone else in it\'s Java form here: Java - Create a new String instance with specified length and filled with specific character. Best so
You can use the first line of the function as a one-liner if you like:
function repeat(str, len) { while (str.length < len) str += str.substr(0, len-str.length); return str; }