Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function generateRandomNumber(array, maxN) {
- let randomN = Math.floor(Math.random() * maxN) + 0;
- console.log(array.length);
- console.log(maxN);
- if(array.length == maxN) {
- array.length = 0;
- }
- if(!array.includes(randomN)) {
- array.push(randomN);
- }
- else {
- randomN = generateRandomNumber(array, maxN);
- }
- return randomN;
- }
- var array = [];
- $("div").on('click', function(){
- console.log('clicked');
- generateRandomNumber(array, 10);
- })
- var array = [];
- $("div").on('click', function(){
- console.log('clicked');
- generateRandomNumber(array, 10);
- console.log(array);
- })
Add Comment
Please, Sign In to add comment