Help us understand the problem. What is going on with this article?

javaScript 乱数 配列 For of ループ For ループ を使ったコード

環境:GAS

目的:

  • 任意の回数配列にランダムな数字(0〜9)を入れ、それを昇順にソートする。
  • 要素ごとにログで出力する
qiita arrayPractice.js
function arrayPractice() {
  let number_list = [];
  const LOOP_COUNT = 20;
  for (let count = 1; count <= LOOP_COUNT; count ++){
    number_list.push(Math.floor(Math.random()*10));
  }
  Logger.log('result for loop' + number_list)  
  let organize_list = number_list.sort()
  // For (element in array){ } の場合、Xは要素番号となります。
  // 上記方法だとLogger.log(array[element])とする必要があります
  for (let number of organize_list){
    Logger.log(number)             
  }
}
kirke
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした