I need a program which will generate typed number of random numbers from 1 to 100. Numbers should be declared in arrays. All numbs have to be sorted descending order. And it should print generated numbers and also print sorted numbers. For example. I typed 4. Program genereated 4 random numbers: 22,80,39,79. Program will print: 22,80,39,79 80,79,39,22 Pls help, this is my homework that I can not do it.
Here is a pages online that can do it for you for free.... graphpad.com/quickcalcs/randomN1.cfm Hope this helps!
Sorry but I cannot write the javascript code so quickly. Hopefully someone else will help you out with the JS code.
Then there is another piece of code that can give something like what you want... Take a look at it here... stackoverflow.com/questions/3796786/random-number-generator-without-dupes-in-javascript
Sort is the easy part, since it's an inherent Javascript method. http://www.w3schools.com/jsref/jsref_sort.asp
var nums = []; var typed = 5; for (var i = 0; i < typed; i++) { nums[i] = Math.ceil(Math.random() * 10); } nums.sort(function(a,b){return a - b}); nums.reverse(); Code (markup): Something like that?