LoginSignup
1
1

More than 1 year has passed since last update.

JavaScriptコードメモ。

Last updated at Posted at 2023-02-01
  1. ランダムな数値を出す。
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;
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1