<html>
<body>
<p id="demo">Click the button to display the extracted part.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
var str="Hello world!";
var n=str.slice(1,5);
document.getElementById("demo").innerHTML=n;
}
</script>
</body>
</html>