Randomly generates 10 0~100 of non-repeating numbers (including 0 and 100);
Knowledge points to use: random numbers
Go heavy
Put the code below
<!DOCTYPE HTML><HTML> <Head> <MetaCharSet= "UTF-8"> <title></title> </Head> <Body> <Script>//The definition declares an array, placing randomly generated 10 numbers vararr= []; for(varI=0; I<Ten; I++){//rounding contains 0 and varN=Math.Round (Math.random ()* -);//Detect Duplicates varoff= false;//assuming random numbers don't repeat. for(varJ=0; J<Arr.length; J++){ if(n==Arr[j]) {//change the state of off if you repeatoff= true;//Jump out of the current code block Break; } }//determine the status of off if(off) {i-- }Else{Arr.push (n); } } </Script> </Body></HTML>
Write code before the idea must be clear, tidy up logic and then write will make your development more effective!
"JavaScript" randomly generates 10 0~100 numbers