Extract only the last character:substring(11, 12) - Javascript String

Javascript examples for String:substring

Description

Extract only the last character:substring(11, 12)

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {//from ww  w  . j  a  v a  2  s .  co  m
    var str = "Hello world!";
    var res = str.substring(11, 12);
    document.getElementById("demo").innerHTML = res;
}
</script>

</body>
</html>

Related Tutorials