String Length

The length of a string is found in the built-in property length. By using the length property, the function will return the number of characters in the string variable named alphabet:

   var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   var stringLength = alphabet.length;

HTML file: Displayed by browser:
<body>
<p id="demo"></p>
<script>
   var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   var stringLength = alphabet.length;
   document.getElementById("demo").innerHTML = alphabet.length;
</script>
</body>


BackTable of ContentsNext