<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Unit 5, Guess</title>
</head>
<body>
<h1>Guess a number</h1>
<script>
function saltarLinea() {
document.write("<br><br><br><hr><br><br>");
}
function imprimir(frase) {
document.write("<big>" + frase + "</big>");
saltarLinea();
}
function sortea(n){
var randomNum = Math.round(Math.random() * n);
return randomNum;
}
alert("Can you guess a number between 0 and 10?");
var numAuto = sortea(10);
var numUser = parseFloat(prompt("Try it! Put your number"));
alert("Let's see if you have guess right.");
if (numUser == numAuto){
imprimir("YOU ARE RIGHT! previously we have choosen the number: " + numAuto + "," + " and yours is: " + numUser);
}else if(numUser > numAuto){
imprimir("Your number is bigger than our, look our number: " + numAuto + "," + " your number was: " + numUser);
}else{
imprimir("Your number is lower than our, look our number: " + numAuto + "," + " your number was: " + numUser);
}
</script>
</body>
</html>