I have successfully implemented the sorting and printout functionality of the program. However, I am now facing a challenge in generating 100 random numbers between 1 and 100, sorting them. I have created an array to store the generated numbers, and I have specified the range from 1 to 100. Despite my efforts, the program is not working correctly. It seems like there might be a missing piece in the code that is preventing it from functioning as expected.
<script>
var arr = [];
while(arr.length < 100){
var r = Math.floor(Math.random() * 100) + 1;
numbers.sort();
numbers.sort(function(a, b){
return a - b;
});
document.write(numbers);
</script>