I have a paragraph of text and want a user to be able to type in the numbers for where a substring should start and end, then have that substring of text printed out when they click a button. But nothing happens when the button is clicked.
Google Chrome gives me this error on the console:
Uncaught TypeError: Cannot read property 'substring' of undefined
HTML
<div>
<h3 id="sentence">You can input numbers below and it will return that interval of characters from this sentence.</h3>
<input type="text" id="input1">
<input type="text" id="input2">
<button type="button" onclick="interval()">Submit</button>
<p id="intervalAnswer"></p>
</div>
JavaScript:
function interval() {
var inputStart = document.getElementById("input1").value
var inputEnd = document.getElementById("input2").value
var string = document.getElementById("sentence").value;
var result = string.substring(inputStart, inputEnd);
document.getElementById("intervalAnswer").innerHTML = result;
}
<h3>useinnerHTMLinstead ofvalue.