Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #39484

Re: Getting 5 random cards at a time.

Newsgroups comp.lang.javascript
Date 2021-02-16 07:16 -0800
References <bd0e7131-00fd-4f81-9ae1-1f90a142aa79n@googlegroups.com> <7b623c9a-7905-4c75-b4bb-5bc895c962bbn@googlegroups.com>
Message-ID <f43da398-c8eb-49da-9f6c-ea57b76ffb18n@googlegroups.com> (permalink)
Subject Re: Getting 5 random cards at a time.
From Kristjan Robam <he12457@hotmail.com>

Show all headers | View raw


There is no question, that i want to ask.
What questions do You have ?


A little fix to the code, for it to look more exciting:


<html><body>

<script>

var y=new Array(2,3,4,5,6,7,8,9,10,'J','Q','K','A','Jo');
var y2=new Array('Hearts','Diamonds','Spade','Clubs');

function y1(a,a2) {
for(var i=Math.round(a/a2)-1; i<=a; i++) {
if((i*a2<=a)&&(a<=(i+1)*a2)) {
return a-i*a2;
break;
}
}
}
function Card() {
var v01=y[y1(Math.round(Math.random()*7458733246324627),y.length)-1]
var v02=y2[y1(Math.round(Math.random()*574354757257835),y2.length)-1];
if(v01=='Jo') return v01;
else return v01+" "+v02;
}

var f1=0;
var f2="";
function f() {
if(f1<5) {
f1++;
setTimeout(function() { f2=f2+" "+Card(); f();}, Math.random()*1517);
} else {
document.write(f2);
}
}
f();

</script>
</body>
</html>




Kristjan Robam 

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Getting 5 random cards at a time. Kristjan Robam <he12457@hotmail.com> - 2021-02-16 04:14 -0800
  Re: Getting 5 random cards at a time. "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2021-02-16 06:19 -0800
    Re: Getting 5 random cards at a time. Kristjan Robam <he12457@hotmail.com> - 2021-02-16 07:16 -0800
      Re: Getting 5 random cards at a time. "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2021-02-16 07:56 -0800
        Re: Getting 5 random cards at a time. Mabor Najtcirk <he12457@hotmail.com> - 2021-02-18 13:49 -0800
          Re: Getting 5 random cards at a time. Mabor Najtcirk <he12457@hotmail.com> - 2021-02-18 13:49 -0800
      Re: Getting 5 random cards at a time. "sc...@sauyet.com" <scott@sauyet.com> - 2021-02-16 11:51 -0800

csiph-web