MV Array Shuffle

I'm testing the fisher yates shuffle on this online editor
JavaScript:
var t0 = [0,0,0,0,0,0,0,0,0,0,0,0,0];
var t1 = [1,1,1,1,1,1,1,1,1,1,1,1,1];
var t2 = [2,2,2,2,2,2,2,2,2,2,2,2,2];
var t3 = [3,3,3,3,3,3,3,3,3,3,3,3,3];
var t4 = t0.concat(t1,t2,t3);

console.log(t4);

var pp = t4; // array cards
for (var i = pp.length - 1; i > 0; i--) {
    const swapIndex = Math.floor(Math.random() * (i + 1))
    const currentCard = pp[i]
    const cardToSwap = pp[swapIndex]
    pp[i] = cardToSwap
    pp[swapIndex] = currentCard
  }
console.log(pp);
console.log(pp[0]);console.log(pp[4]);console.log(pp[8]);console.log(pp[12]);

this is the output.. as you can see the array is shuffled correctly..
1620271308288.png

however in RMMV..
1620271364958.png

this is the output.. i dont know what is wrong
1620271453676.png
I think maybe the last show text should be \v[5] instead...?
since you store pp to variable 5...

i don't see any other problem though...
I think maybe the last show text should be \v[5] instead...?
since you store pp to variable 5...

i don't see any other problem though...
it's still the same i tried \v[4] \v[5], on that line, and they output the same.. its like the shuffle is only done once..

EDIT:
I swapped with another version of fisher yates.. this once works
JavaScript:
var i = arr.length, j, temp;
while(--i > 0){
    j = Math.floor(Math.random()*(i+1));
    temp = arr[j];
    arr[j] = arr[i];
    arr[i] = temp;
}
generically:
Code:
i = t4[random(t4.length-1)]
pp.unshift(t4.pop(i))

get total of items.
randomize based on total.
remove index number from total -> total decreases by 1.
repeat.

you don't need to reorder pp, you need to create pp based on the items of t4.
this
JavaScript:
var i = arr.length, j, temp;
while(--i > 0){
    j = Math.floor(Math.random()*(i+1));
    temp = arr[j];
    arr[j] = arr[i];
    arr[i] = temp;
}

is the bubble method for sorting.
generically:
Code:
i = t4[random(t4.length-1)]
pp.unshift(t4.pop(i))
is this shorter method? this is for deck of cards. im making a game dealing cards, players get 4 cards on their hand.

Original thread: https://forums.rpgmakerweb.com/threads/array-shuffle.136248/