This is my first post! I'm studying a book by Marcus Geduld named After Effects Expressions and ran into a function that confuses me. I'm just wondering if someone is able to help me break it down to the basics. The purpose is to randomly pick a different value for rotation on every frame.
I'd appreciate any help, cheers.
function pickRandomNumber(arrayOfNumbers) // Define the function and the input.
var randomNumber = random(arrayOfNumbers.length); // Randomly generate numbers, but within the range (length) of arrayOfNumbers?
var myIndex = Math.floor(randomNumber); // Take the numbers generated from randomNumber and round them down?
return arrayOfNumbers[myIndex]; // I don't understand what is happening here. Are we determining how this part of the function works or will accept myArray?
myArray = [10,20,30,40,50,60]; // Got it, this is an array of numbers.
pickRandomNumber(myArray); // Call the pickRandomNumber function and use myArray as the input?