function send(uname, len) { var str = new Array(len + 1).join(uname).match(new RegExp(uname,"g")); return str; } alert(send('hello', 5));