shuffle json array javascript
function shuffle(arra1) {
var ctr = arra1.length, temp, index;
// While there are elements in the array
while (ctr > 0) {
// Pick a random index
index = Math.floor(Math.random() * ctr);
// Decrease ctr by 1
ctr--;
// And swap the last element with it
temp = arra1[ctr];
arra1[ctr] = arra1[index];
arra1[index] = temp;
}
return arra1;
}
var myArray = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
console.log(shuffle(myArray));
Also in JavaScript:
- react native pm ERR! code EINTEGRITY
- javascript Bingo add called number to a list
- clear formarray in angular 6
- how to use for of in javascript
- js remove element from array
- bootstrap in javascript
- length of an object in javascript
- vuetify event handler
- how to convert date to string in javascript
- function range() as range js
- new file shortcut vscode
- counter composant react
- href javascript void
- jquery button remove disabled attribute
- background image with styled components
- select option trigger in js
- function prototype javascript
- dont starve together
- enzynme not support react 17
- how to do a classname variable and string react
- palindrome
- sum javascript
- delegate jquery
- how get parent element javascript