Page 1 of 1

[Help] My array won't change when looping pages

Posted: Fri Feb 11, 2022 1:00 pm
by Epton
Why does my tease get stuck on 1 phrase out of the array?
My tease is looping between 3 pages.

I've used this code

Code: Select all

var rest = [
"No touching",
"Hands on head",
"Hands up high in the air",
"Hands behind the head",
"Sit on your hands"
]

var restRandom = rest[Math.floor(Math.random()*rest.length)]

Re: [Help] My array won't change when looping pages

Posted: Fri Feb 11, 2022 7:05 pm
by Thamrill
Epton wrote: Fri Feb 11, 2022 1:00 pm Why does my tease get stuck on 1 phrase out of the array?
My tease is looping between 3 pages.

I've used this code

Code: Select all

var rest = [
"No touching",
"Hands on head",
"Hands up high in the air",
"Hands behind the head",
"Sit on your hands"
]

var restRandom = rest[Math.floor(Math.random()*rest.length)]
Just tested it out and multiple invocation of "rest[Math.floor(Math.random()*rest.length)]" provides all the results.

Just to be sure, you are invoking "restRandom = rest[Math.floor(Math.random()*rest.length)]" everytime you expect a new result, right?