xxxxxxxxxx
<html>
<head>
</head>
<body>
<h1>Add Space Before Capital Letter Javascript</h1>
<input type="text" id="inputText" value="ThisIsJavascriptTutorial" />
<button onclick="updateOutput()">Update Output</button>
<p id="output"></p>
<script>
function insertSpaceBeforeCapitalLetters(str) {
return str.replace(/([A-Z])/g, " $1").trim();
}
function updateOutput() {
const input = document.getElementById("inputText").value;
const result = insertSpaceBeforeCapitalLetters(input);
document.getElementById("output").textContent = result;
}
</script>
</body>
</html>