I know how do this in PHP, but in javascript arrays are weird.
So I have a set of image transitions which have effects that use easing equations. For certain effects I want to pick up a random value from a array of multiple values:
something like:
easing: randomFrom(array('easeOutElastic', 'easeOutBounce', 'easeOutSince')),
function randomFrom(array) {
return array[Math.floor(Math.random() * array.length)];
}
// in your code
easing: randomFrom(['easeOutElastic', 'easeOutBounce', 'easeOutSince']),
Try this:
function randomFrom(arr){
var randomIndex = Math.floor(Math.random() * arr.length);
return arr[randomIndex];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With