0

i dont want that there comes the same numbers at the same time

what i have to add, what is the best ? need some help here can you find my code https://code.sololearn.com/W9165KUpI99P/#html

19th Jun 2017, 2:47 PM
Robert Tressa
Robert Tressa - avatar
9 odpowiedzi
+ 1
Use for loop generate random number check if it is already generated if yes generate another number
19th Jun 2017, 3:21 PM
Da' BO$
Da' BO$ - avatar
+ 1
You need to add function to do checking and ensure unique result. I modified your update of "number" array using below statement: number[0] = (()=>{ do{ n = Math.floor((Math.random() * 50) + 1)}while(number.includes(n)); return n;})(); Check out the modified code here: https://code.sololearn.com/WTLHrM42d9Ld/?ref=app
19th Jun 2017, 3:48 PM
Calviղ
Calviղ - avatar
+ 1
function getSortNumbers() { var num = new Array(); for(var i=0; i<7; i++) { ran=0; while(true) { ran= Math.floor((Math.random() *50) +1); if(num.includes(ran)) continue; else break; } num.push(ran); } return num; }
19th Jun 2017, 4:29 PM
Da' BO$
Da' BO$ - avatar
19th Jun 2017, 3:16 PM
Calviղ
Calviղ - avatar
0
doesnt work by me ^^
19th Jun 2017, 3:20 PM
Robert Tressa
Robert Tressa - avatar
0
What do you mean by "i dont want that there comes the same numbers at the same time"?
19th Jun 2017, 3:21 PM
Calviղ
Calviղ - avatar
0
@Wondwosen Abebaw how? im not so far :/
19th Jun 2017, 3:23 PM
Robert Tressa
Robert Tressa - avatar
0
@calvin like and not 1 2 2 2 3 3 4 3 6 5 7 7
19th Jun 2017, 3:25 PM
Robert Tressa
Robert Tressa - avatar
0
@Calvin Thank you so much, i kiss your eyes Bro
19th Jun 2017, 3:58 PM
Robert Tressa
Robert Tressa - avatar