<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>zgadywanka</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="generator" content="Geany 1.35" />
</head>
<body>
<script>
function Komunikat(tekst){
document.write(tekst + '<br>');
}
Komunikat('Zgadnij liczbe z zakresu 0-100. Powodzenia!')
liczbaPodejsc = 0
var wynik = [];
var gramyDalej = true;
while (true){
for (liczbaPodejsc=0; liczbaPodejsc<10; liczbaPodejsc++){
if(liczbaPodejsc == 0){
imie=prompt('Dawaj imie !!!')
var start = Date.now();
losowa = Math.round(Math.random()*100)
//document.write(losowa)
}
propozycja = prompt(' Dawaj liczbę !!!')
if (losowa == propozycja)
{Komunikat('Trafiłeś!')
var stop = Date.now();
czas_ms = (stop - start)/1000;
wynik.push({imie, czas_ms});
liczbaPodejsc=10;
break
}
if (losowa<propozycja)
{Komunikat('Podaj mniejszą liczbe!')
}
else {Komunikat('Podaj wiekszą liczbe!')
}
}
koniec_podejsc = prompt('Czy chcesz zagrać jeszcze raz? t=tak');
if (koniec_podejsc != 't') {break};
koniec_zabawy = prompt('Czy chcesz zagrać jeszcze raz? t=tak');
if (koniec_zabawy != 't') {break};
}
console.log(wynik);
console.log(wynik[0].imie);
function porownaj(a, b){
return a.czas_ms-b.czas_ms
}
console.log(wynik.sort(porownaj));
function pokaz(wynik){
document.write(wynik.imie + " | " + wynik.czas_ms, "</br>")
}
wynik.forEach(pokaz)
console.log(wynik);
</script>
</body>
</html>
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}