Is there a way to randomize values in a variable?

It is literally in the title.

Example Code

var x = ["a", "b", "c"];
//put random value generator here for x

If you’re talking about randomizing the order, then yes.

function shuffleArray(array) {
    for (var i = array.length - 1; i > 0; i--) {
        var j = Math.floor(Math.random() * (i + 1));
        var temp = array[i];
        array[i] = array[j];
        array[j] = temp;

I found this on Stack Overflow by Laurens Holst.

I meant like that it would choose a random value from the variable (and maybe do it 3 times).

Ohhh OK. For that, you’ll just want to get a random item from the array:

array[randomNumber(0, array.length-1)]

If you want to get 3 items and you don’t want repeats, just do this:

var _og = arrayVariable;
var _re = []; // The three random items
for (var i = 0; i < 2; i++) {
  var _i = randomNumber(0, _og.length-1);
  _og.splice(_i, 1);

Hope it works :+1:

Sorry if I’m a bit confused about this, but how do you use it because I have never worked with arrays.

_re is the array with the 3 random items selected.