// Generate an array of random numbers
const data = [];
for (let i = 0; i < 10; i++) {
data.push(Math.floor(Math.random() * 100));
}
console.log(data); // Output: [47, 92, 27, 53, 37, 31, 60, 26, 21, 58]
// Sort the array in ascending order
for (let i = 0; i < data.length; i++) {
for (let j = 0; j < data.length; j++) {
if (data[j] > data[j + 1]) {
// Swap the elements
const temp = data[j];
data[j] = data[j + 1];
data[j + 1] = temp;
}
}
}
console.log(data); // Output: [21, 26, 27, 31, 37, 47, 53, 58, 60, 92]