Thread: Problem array, if! View Single Post
12-05-2012, 09:37 PM   PM User | #7
Old Pedant
Supreme Master coder!

Join Date: Feb 2009
Posts: 24,962
Thanks: 75
Thanked 4,309 Times in 4,276 Posts
Quote:
 Originally Posted by triko OK! as usual I haven't explained... I have the problem of the game roulette... When click start, put out one number random from 0 to 36 Code: ```THIS CODE IS WRONG AS NOTED BY WOLFSHADE var ball = Math.floor(Math.random()*36);``` before I have all my bets, example corners, split, red or black ecc... My problem born for corner, split, column, dozen ecc... Because I have all array of the possible combination, example columns: Code: ``` var col1 = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34]; var col2 = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35]; var col3 = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36];``` ...
And we *GAVE* you the RIGHT ANSWER!!!

Code:
```if ( col1.indexOf( ball ) >= 0 )
{
// ball is in col1
} else if ( col2.indexOf( ball ) >= 0 ) {
// ball is in col2
} else if ( col3.indexOf( ball ) >= 0 ) {
// ball is in col3
} else ... other tests ...```
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.