I made a code that prints a sequence of numbers, from the number entered to the end, but when I print it the last number is not appearing.
Example: first number entered is 3 and second is 7. The sequence would be 3, 4, 5, 6, 7, but 7 does not appear.
function id(valor_campo)
{
return document.getElementById(valor_campo);
}
function getValor(valor_campo)
{
var valor = document.getElementById(valor_campo).value;
return (valor);
}
function nums(valores)
{
var inicio = getValor("num1");
var fim = getValor("num2");
var res = 0;
while (inicio < fim)
{
res += (inicio)+"<br>";
inicio++;
}
document.getElementById("demo").innerHTML = res;
}
<html>
<head>
<meta charset="utf-8">
</head>
<body>
Valor 1: <input type="number" name="num1" id="num1"> <br><br>
Valor 2: <input type="number" name="num2" id="num2"> <br><br>
<button onclick="nums()">Saiba a sequência dos números digitados!</button>
<p id="demo"></p>
</body>
</html>