im very confused , to explain my problem and I have searched in various posts in here, but I can't find the solution I'm facing . so i want to ask, its possible to call an array sort of data in java script one by one after the button is clicked ? explain I have a script random like this
$(document).on("click", "#okok", function() {
var myArray = [
"5",
"8",
"7",
"2"
];
var randomItem = myArray[Math.floor(Math.random() * myArray.length)];
var nilai = document.getElementById("pr");
nilai.value = randomItem;
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<textarea name="pr" id="pr"></textarea>
<br>
<input type="button" id="okok" value="Start">
the script above displays array data one by one but random and not sort.. so i want the display data sort and not random like 2 , 5 ,7 ,8
thanks