x
<html>
<body>
<h2>JavaScript String.trim()</h2>
<p>Click the button to alert the string with removed whitespace.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
let text = " Hello World! ";
alert(text.trim());
}
</script>
</body>
</html>