how to find length of string in javascript without using length method code example
Example 1: how to find length of string in javascript without using length method
function strLength(s) {
var length = 0;
while (s[length] !== undefined){
length++;
}
return length;
}
console.log(strLength("Hello")); // 5
console.log(strLength("")); // 0
Example 2: javascript create string of given length
var str = new Array(len + 1).join( character );