So basically this is what I'm trying to do. My code runs an AJAX get request on some external JSON data that's stored in arrays (as you can see below).
My code works great.
However I want to apply the same random value on the actual entry number that it's retrieving for both variable sa and ss.
var sa = (index.Of['10']['blah:blah'].label + ' ');
var ss = (index.Of['10']['blah:blah'].label);
var sS = (sa + ss);
So I can do this with one variable with no issue, in the following code by doing it this way.
var sa = (index.Of[Math.floor(Math.random() * 10) + 1]['blah:blah'].label + ' ');
var ss = (index.Of[Math.floor(Math.random() * 10) + 1]['blah:blah'].label);
var sS = (sa + ss);
BUT the issue is that I don't know of a way to apply the same math.floor randomization array value to both variables.
I'm stumped.
Math.floor(Math.random() * 10)to be the same every time, just uselet rand = 1 + Math.random() * 10 | 0and use therandvariable in place ofMath.floor….