Skip to content

Instantly share code, notes, and snippets.

@dator-zz
Created October 5, 2012 12:21
Show Gist options
  • Save dator-zz/3839518 to your computer and use it in GitHub Desktop.
Save dator-zz/3839518 to your computer and use it in GitHub Desktop.
CorrectionTP
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="main.css">
</head>
<script type="text/javascript">
var compteur = 5,
nb = Math.floor(Math.random() * 100),
resp = null;
do {
resp = prompt('Trouve le nombre ('+nb+')entre 1 et 100, il vous reste '+compteur+' chances');
if(resp > nb){
alert("C'est plus petit");
compteur--;
} else if(resp < nb) {
alert("C'est plus grand");
compteur--;
} else {
document.write('Gagn&eacute;');
}
if(compteur == 0) {
alert('perdu');
break;
}
}while(nb != resp);
</script>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment