<html lang="en">
<head></head>
<body>
<p id="inputString">AddSpaceBeforeCapitalLetterJavascriptWithoutRegex</p>
<p id="output"></p>
<button onclick="addSpaces()">Add Spaces</button>
<script>
function addSpaceBeforeCapital(str) {
let result = '';
for (let i = 0; i < str.length; i++) {
if (str[i] === str[i].toUpperCase() && str[i] !== ' ' && i !== 0) {
result += ' ';
}
result += str[i];
}
return result;
}
// Example usage:
function addSpaces() {
let inputString = document.getElementById('inputString').textContent;
let stringWithSpaces = addSpaceBeforeCapital(inputString);
document.getElementById('output').textContent = stringWithSpaces;
}
</script>
</body>
</html>