-1
I am learning Javascript and am having trouble showing on the screen the loop of numbers placed inside the inputs.
function contar(){
var inicio = Number(document.getElementById('inicioNumero').value)
var fim = Number(document.getElementById('fimNumero').value)
var passo = Number(document.getElementById('passoNumero').value)
var res = document.getElementById('res')
for(var i = 0; i <= fim; i+= passo){
res+=(`=>${i}`)
}
document.getElementById('contar').innerText = res
}
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Super Contador</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<header>
Vamos Contar
</header>
<section>
<div>
Início: <input type="number" name="inicio" id="inicioNumero">
</div>
<div>
Fim: <input type="number" name="fim" id="fimNumero">
</div>
<div>
Passo: <input type="number" name="passo" id="passoNumero">
</div>
<div id="button">
<input type="submit" value="Calcular" onclick="contar()">
</div>
<div id="res">Calcular:</div>
</section>
<script src="js/script.js"></script>
</script>
</body>
</html>
has some errors in your code: 1) on that line
var res = document.getElementById('res')
is picking up the element, but on the lineres+=(
=>${i})
is adding something, that can not be done in the element, I think you want the content, right? then missed take the content of div:var res = document.getElementById('res').innerText
for example. 2) after thefor
is trying to use an element that does not exist in html, the "count". Here would not be the element "res"? or create the element with ID="count"– Ricardo Pontual