/ Published in: JavaScript
first of all i thank to our Creator and Mr.ImHugo for his Action script which i make the java script from it,its works fine and once again i gives thank him for his snippet
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
# // ************************************************** // # // Author: John Sujith Kumar # // URL: http://www.suzerain.isgreat.org # // ************************************************** // # # // Vars function uniqueRandomNumber(inPutArray){ var sArray = new Array(); var storeList = new Array(); // Inserts Numbers in Array for(var i= 1; i<=inPutArray; i++){ sArray.push(i); } // Outputs numbers non-repeated for(var k= 1; k<=inPutArray; k++){ // Search for value inside the Array in a random position var randomPos= Math.floor( Math.random() * sArray.length ); // Selects value and removes it from Array var valueFromArray = sArray.splice(randomPos, 1); // Converts value in number var numberRand = parseInt(valueFromArray); //store and make array key for as like 0,1,2 for length :3 storeList.push(numberRand-1); } alert(storeList); } uniqueRandomNumber(3);