<html>
<title>Reverse a string in javascript</title>
<body>
<center><br>
<label>Enter Any String:</label> <input type="text" id="str">
<button type="button" id="btn" onclick="revString()"> Reverse String</button><br>
<hr>
<h2 style="color:green" id="orgString"></h2>
<h2 style="color:green" id="revString"></h2>
</center>
</body>
<script type="text/javascript">
function revString() {
let str = document.getElementById('str').value;
let revString = '';
document.getElementById('orgString').innerHTML = 'Original String: '+str;
for (var i = str.length - 1; i >= 0; i--) {
revString+= str[i];
}
document.getElementById('revString').innerHTML = 'Reverse String: '+revString;
}
</script>
</html>