JRS: In article <ea**************************@posting.google.com >, seen
in news:comp.lang.javascript, Jim Davidson <ra*****@icubed.com> posted
at Tue, 16 Sep 2003 12:42:08 :-
I'm teaching myself javascript and need some help with this code. can
someone tell me what's wrong with it?
It is possible to tell you some of what is wrong with it; for example,
string_of_ImgNo is undefined at the point of use, although that only
really matters if you intend to call the function getRandomNo.
But, as you have not said what you might want it to do, we cannot tell
you all that may be wrong with it, unless we guess the purpose.
My guess is that you want to return a ten-character string which is a
random permutation of '0123456789'; or that you want to return a digit
not previously used, which can be done by indexing into such a pre-
prepared permutation.
So you should read the newsgroup FAQ, searching for information on the
use of Random; the apparent problem is equivalent to dealing a deck of
ten cards 0..9. You will find a link to <
http://www.merlyn.demon.co.uk/
js-randm.htm>.
Consider :
var RA = Deal(10), N=0, S=''
function Next() { return RA[N++] }
for (j=0; j<12; j++) S += Next()
document.writeln(RA, ' ',S)
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.