I'm trying to make a program that takes three numbers from the user and gives them the biggest and smallest, but sometimes the numbers are flipped (The biggest is switched with the smallest), and sometimes some numbers just get left out. Can anyone tell me what is happening?
const testArray = [
prompt(`Pick a number`),
prompt(`Pick a number`),
prompt(`Pick a number`),
];
let max = testArray[0];
let min = testArray[0];
for (let i = 1; i < testArray.length; i++) {
if (testArray[i] > max) max = testArray[i];
if (testArray[i] < min) min = testArray[i];
}
console.log(`The biggest number you chose was ${max}`);
console.log(`The smallest number you chose was ${min}.`);
Somehow the numbers get flipped, or some numbers get left out.