- ランダムな数値を出す。
const numbers = [1, 2, 3, 4, 5];
for(let i = 5; i > 0; i--){
const randomNum = Math.floor(Math.random() * i);
let tmp = numbers[i - 1];
numbers[i - 1] = numbers[randomNum];
numbers[randomNum] = tmp;
}
Go to list of users who liked
More than 1 year has passed since last update.
const numbers = [1, 2, 3, 4, 5];
for(let i = 5; i > 0; i--){
const randomNum = Math.floor(Math.random() * i);
let tmp = numbers[i - 1];
numbers[i - 1] = numbers[randomNum];
numbers[randomNum] = tmp;
}
Register as a new user and use Qiita more conveniently
Go to list of users who liked