Creating array of length n with random numbers in JavaScript

后端 未结 6 1712
耶瑟儿~
耶瑟儿~ 2020-12-09 03:44

Following up on this answer for creating an array of specified length, I executed the below to get a corresponding result but filled with random numbers, instead of zeros.

6条回答
  •  余生分开走
    2020-12-09 04:35

    Solution from Sized array of random unique numbers

    const uniqRandomNumbers  = _.sampleSize(_.range(9), 4);
    console.log(uniqRandomNumbers);

提交回复
热议问题