Syntax
{ A Statement; }
JavaScript Statement Example
Here in this example, I have written few statements that tells the browser to write a word in its original form and later using a while statement, reverse the word.
<html> <body> <input type='text' id='tb' value='COMPUTER SCIENCE' /> <input type='button' value='Click it' onclick='reverse_text()'> <p id='result'></p> </body> <script> let reverse_text = () => { let sWord = document.getElementById('tb').value; let res = document.getElementById('result'); res.innerHTML = 'You have entered: ' + sWord; res.innerHTML = res.innerHTML + '<br /><br />'; let i = sWord.length; res.innerHTML = res.innerHTML + ' ' + '<b> is now Reveresed </b> <br /><br />'; while (i--) { res.innerHTML = res.innerHTML + ' ' + sWord[i]; } } </script> </html>
The result,