字符串:23456,16524,84755,98457,06978,05986,73454,34785
23456
16524
84755
98457
06978
05986
73454
34785
答案 0 :(得分:0)
只需explode()即可通过逗号分隔符来分解字符串。
var numberOfCubes = 8;
var rotationsSet = [
'rotateX(90deg)',
'rotateX(-90deg)',
'rotateY(90deg)',
'rotateY(-90deg)',
'rotateX(180deg)'
];
var shuffledRotationsSets = Array(numberOfCubes).fill(['']);
// Fisher-Yates array shuffle
function shuffle(array) {
for (let i = array.length - 1; i > 0; i--) {
let j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
}
function initShuffledSets() {
for (let z = 0; z < shuffledRotationsSets.length; z++) {
shuffledRotationsSets[z] = rotationsSet;
shuffle(shuffledRotationsSets[z]);
}
}
initShuffledSets();
工作demo。