:cookie: 16 | @hansuno2 |http://www.freecodecamp.org/hansuno2
:cookie: 310 | @sfshameem5 |http://www.freecodecamp.org/sfshameem5
<html>
<h1>Type a number between 1 - 10</h1>
<form action="" name="form1">
<input type="text" name="text" width="20px">
<button onClick="init()">Press</button>
</form>
</html>
var numb = Math.floor(Math.random() * 10 +1);
function init() {
var inicio = document.form1.text.value;
console.log("coge");
}
function check() {
var count = 0;
var acept = init();
if(acept == numb) {
showWin();
count++;
} else if( acept !== numb) {
showError();
count++;
} else if((acept !== numb) && (count == 5 )) {
showLoss();
count++;
}
}
function showWin() {
console.log("gano!");
}
function showError() {
console.log("perdio");
}
function showLoss() {
console.log("mas de cinco veces, perdio");
}
:cookie: 17 | @hansuno2 |http://www.freecodecamp.org/hansuno2
:star2: 1214 | @marmiz |http://www.freecodecamp.org/marmiz