Needing to write a function that returns a number between 0 and 6 (inclusive)with the following probabilities:
0: 10%, 1: 26%, 2: 33%, 3: 18%, 4: 9%, 5: 3%, 6: 1%
While this is likely best done with objects, I'm not that far along... so think I need to iterate over 2 arrays (say var values=[ 0,1,2,3,4,5,6]
and var weights=[10, 26, etc]
My ridiculous question: in arrays: how do I return values[i]
a [weighted]
number of times .... all my syntax efforts return the two values multiplied (basically values[i] * weighted[i]
).