Use the length property to display the length of a string variable's value. - Javascript String

Javascript examples for String:Quiz

Description

Use the length property to display the length of a string variable's value.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="demo"></p>

<script>
var txt = "Hello World!";
document.getElementById("demo").innerHTML = txt.length;
</script>/*from   w ww.j a v  a  2  s . c o m*/

</body>
</html>

Related Tutorials