Need help with a Random Card Generator

Hello,

Am looking for a hand with a personal project that am working on. You can view it here, but please bare in mind that it is not complete. The functionality in question is on the homepage.

https://cosmic-runes.webflow.io/

I have integrated some Javascript that I found on the forum, which seems to successfully present 3 cards to the user, but after trialling this 100+ times, it seems that it isn’t really random at all and it seems to favour certain cards more than others (the last items uploaded to the collection).

The code I’m using is here:

<script>
  $(document).ready(function() {
    var show_limit = 3;
$('.card-flip-item').each(function(){
  if (   $(this).index() >= show_limit) {
     $(this).addClass('hidden-list-item');

   	 }
  });
});

var cards = $(".card-flip-item");
for(var i = 0; i < cards.length; i++){
    var target = Math.floor(Math.random() * cards.length -1) + 1;
    var target2 = Math.floor(Math.random() * cards.length -1) +1;
    cards.eq(target).before(cards.eq(target2));
}

If this is something that you can help with, please send me a private message.

Hello,
I would be glad to assist you.
Sent you PM with further details.
Thanks!
Trish

Hey there,

Greetings!

Sent you pm,please check.

Regards
Ron