<META charset="UFT-8">
<script>
function jump() {
document.write("<br><br>");
}
function show(frase) {
document.write(frase);
jump();
}
function draw(n) {
return Math.round(Math.random() * n);
}
// show welcome msg
alert("* Welcome to our guessing game! *");
alert("You should choose a number between 1 and 10 for your kick.");
// game
var secretNumber = draw(10);
console.log(secretNumber);
var attempt = 1;
while (attempt <= 3) {
var kick = parseInt(prompt("What's your kick? "));
if (kick == secretNumber) {
show("<h1>You win! The secret number was " + secretNumber + "</h1>");
break;
} else {
if (kick > secretNumber) {
alert("The secret number is less than this.");
} else {
alert("The secret number is bigger than this.");
}
}
attempt++;
}
show("<h1>End Game</h1>");
</script>