Skip to content

Instantly share code, notes, and snippets.

@henrycunh
Last active May 20, 2018 21:26
Show Gist options
  • Save henrycunh/4f18f84f10196e918dbe144bfa3c15e5 to your computer and use it in GitHub Desktop.
Save henrycunh/4f18f84f10196e918dbe144bfa3c15e5 to your computer and use it in GitHub Desktop.
Exercicio Bilbo
let elEntrada = document.getElementById('entrada')
let elSaida = document.getElementById('container')
let elForm = document.getElementById('formulario')
const gerarNumeros = (evento) => {
evento.preventDefault()
let numero = parseInt(elEntrada.value)
let saida = ""
for(let i = 0; i < numero; i++)
saida += Math.round(Math.random() * 100) + "<br>"
elSaida.innerHTML = saida
}
elForm.addEventListener('submit', gerarNumeros)
<!DOCTYPE html>
<html>
<head>
<style>
body{
background: #333;
font-family: monospace;
color: #fff;
padding: 1em;
}
input, button{
font-family: monospace;
border-radius:5px;
padding: .5em 1em;
}
#container{
border: 2px dotted #666;
padding: 1em;
}
</style>
<title>Exercício</title>
</head>
<body>
<form id='formulario'>
<h2>Digite o valor</h2>
<input id='entrada'/>
<button type='submit'>Testar</button>
<h2>Números</h2>
<div id='container'></div>
</form>
</body>
<script src='app.js'></script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment