let length = 10, max = 9; let newArr = Array.from({length}, (_, i) => !i + Math.round(Math.random() * (max - !i))); console.log(newArr)