MV Pulling random integer from an array

So I've setup an array with:
$gameVariables.setValue(533, [2, 3, 4]);

And then I pull a random integer from the array with:

$gameVariables.setValue(534, $gameVariables.value(533).splice(Math.floor(Math.random() * $gameVariables.value(533).length), 1))

It looks like it works when I check the variable in game:
var_result.PNG


But the event doesn't trigger when checking for this value:
battle.PNG


Anyone have any idea why and how to fix?
I'm not a programmer, so I am probably misusing terms here, but a problem with using arrays is that when you pull an element from an array, you pull it as an array of one element, which is not the same as that number, so what you need to do is extract the number from the single element array with one extra step, using parseInt().

$gameVariables.setValue(534, parseInt($gameVariables.value(533).splice(Math.floor(Math.random() * $gameVariables.value(533).length), 1)))

And then it will work.
Like LadyJJ says, you've assigned the value [2], not 2. I'd suggest indexing the first element (index 0) of the splice result:
JavaScript:
$gameVariables.value(533).splice(Math.randomInt($gameVariables.value(533).length))[0]
This can be used with any value type. I've also used RMMV's built-in Math.randomInt method here, since it's shorter to write~

By default when you coerce an array to string (e.g. for display on the in-game debug menu) it shows the array elements, without [brackets], joined by a ,. In this case that looks just the same as if the value was the number you meant to assign, even though the actual value is different.
@Lady_JJ @caethyril Thank you both for the help!

Original thread: https://forums.rpgmakerweb.com/threads/pulling-random-integer-from-an-array.138358/