js create string of length code example
Example 1: js string length
let str = "foo";
console.log(str.length);
Example 2: length of string in javascript
var str = "Hello World!";
var n = str.length;
Example 3: repeat js
repeatStr = (n, s) => s.repeat(n);
Example 4: string repeat
repeatStr = (n, s) => s.repeat(n);
function repeatStr(n, s) {
return s.repeat(n);
}
function repeatStr(n, s) {
var str = "";
for (var i = 0; i < n; i++) str += s;
return str;
}
Example 5: javascript create string of given length
var str = new Array(len + 1).join( character );