How to create an array with random values in Node.js

1 Answer

0 votes
let size = 5;

const arr = Array.from({length: size}, val => Math.floor(Math.random() * 100));

console.log(arr) 



/*
run:

[ 70, 8, 86, 34, 79 ]

*/

 



answered Mar 22, 2024 by avibootz
...