I want to run element in for loop for many times but how? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

I want to run element in for loop for many times but how?

let Array =[ "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "5", "5", "5", "5", "5", "5", "5", "10", "10", "10", "10", "2roll", "2roll", "2roll", "chance", "chance", "4roll", ] var t = 0; var i = 10; const randomIndex = Math.floor(Math.random() * Array.length); const randomElem = Array[randomIndex]; console.log(randomElem); for (var element of randomElem ) { if(element ===1) { t = t + i; console.log(element ) console.log(t) console.log(i) } else { t = t - i; i = i * 2; console.log(element ) console.log(t) console.log(i) } } I want multiple outputs .. at least 50

8th May 2020, 7:53 AM
Tharun
Tharun - avatar
57 ответов
+ 6
If you want to loop somethink, just write "infinite" after the time it takes to complete a loop
8th May 2020, 4:55 PM
Manuel José Muñoz Bonilla
Manuel José Muñoz Bonilla - avatar
+ 1
I just want to try it
8th May 2020, 9:50 AM
Tharun
Tharun - avatar
+ 1
Have u played wheel of fortune
8th May 2020, 9:51 AM
Tharun
Tharun - avatar
+ 1
What do u mean range?
8th May 2020, 9:57 AM
Tharun
Tharun - avatar
+ 1
From the array
8th May 2020, 9:58 AM
Tharun
Tharun - avatar
0
Please tell me what do you want and what are you doing?
8th May 2020, 8:38 AM
ycsvenom
ycsvenom - avatar
0
I just wanted to create a strategy to win in wheel of fortune
8th May 2020, 9:28 AM
Tharun
Tharun - avatar
0
And how do you want to do that? It's completely random!! There is no way to do that!!
8th May 2020, 9:31 AM
ycsvenom
ycsvenom - avatar
0
The only way is to make a program that make a fixed swip
8th May 2020, 9:33 AM
ycsvenom
ycsvenom - avatar
0
I just want to get random element continuously and pass it to for loop .. plz let me know how to do it
8th May 2020, 9:51 AM
Tharun
Tharun - avatar
0
Then elaborate it in details
8th May 2020, 9:51 AM
ycsvenom
ycsvenom - avatar
0
Then this would make sense to u
8th May 2020, 9:52 AM
Tharun
Tharun - avatar
0
Who doesn't played it?!
8th May 2020, 9:52 AM
ycsvenom
ycsvenom - avatar
0
I have the strategy to only place bet on 1 so I want to check
8th May 2020, 9:53 AM
Tharun
Tharun - avatar
0
I want to check What will is the profit if u continuously bet on 1 by doubling it every time using a random number generator
8th May 2020, 9:54 AM
Tharun
Tharun - avatar
0
How many random numbers do you want?
8th May 2020, 9:54 AM
ycsvenom
ycsvenom - avatar
0
At least 50 ( that means 50wheel spins)
8th May 2020, 9:54 AM
Tharun
Tharun - avatar
0
And what is the range of random numbers?
8th May 2020, 9:56 AM
ycsvenom
ycsvenom - avatar
0
May u just type in playground and add link ?
8th May 2020, 9:56 AM
Tharun
Tharun - avatar
0
There only 4 numbers 1 , 2 , 5 ,10 that appear multiple times
8th May 2020, 9:58 AM
Tharun
Tharun - avatar