I'm working on a quick little exercise, and I am trying to allow a user to input 5 random numbers and have my script arrange them in ascending order, however it only works on single digit numbers. For example, when a user inputs 27, the program sorts it as if it were simply a 2. I am not certain what is causing this to happen, and I am open to any suggestions. (Also, code is not as concise as possible but please overlook)
let array = [];
let scrapArray = [];
array[0] = prompt("Please input a random number");
array[1] = prompt("Please input another random number");
array[2] = prompt("Please input another random number");
array[3] = prompt("Please input another random number");
array[4] = prompt("Please input another random number");
for (let i = 0; i < 5; i++) {
for (let j = (i + 1); j < 5; j++) {
if (array[i] >= array[j]) {
scrapArray[i] = array[i];
array[i] = array[j];
array[j] = scrapArray[i]
}
}
}
console.log("the order of numbers from lowest to highest is: ");
for (let m = 0; m < array.length; m++) {
console.log(array[m]);
}