how to create a string based on length in javascript code example Example: javascript create string of given length var str = new Array(len + 1).join( character );