JSFiddle - React, Tailwind, and code Playground

by Chintan Upadhayay

HTML

<a href="#one" class="hash">One</a> 
<div>
    <p>some text</p>
</div>
<a href="#two" class="hash">Two</a> 
<div>
    <p>some text</p>
</div>
<a href="#three" class="hash">Three</a> 
<div>
    <p>some text</p>
</div>

CSS

div {
    height: 400px;
}

JavaScript

var items = Array(523, 3452, 334, 31, 5346);
var item = items[Math.floor(Math.random() * items.length)];

console.log(shuffle(items));

function shuffle(array) {
  var currentIndex = array.length, temporaryValue, randomIndex;

  // While there remain elements to shuffle...
  while (0 !== currentIndex) {

    // Pick a remaining element...
    randomIndex = Math.floor(Math.random() * currentIndex);
    currentIndex -= 1;
console.log(randomIndex);
    // And swap it with the current element.
    temporaryValue = array[currentIndex];
    array[currentIndex] = array[randomIndex];
    array[randomIndex] = temporaryValue;
  }

  return array;
}