用js寫三個數,讓三個數從小到大排列

YKmaster發表於2018-05-19
console.log(`請輸入三個數:`);
let num1 = readline.question() – 0;
let num2 = readline.question() – 0;
let num3 = readline.question() – 0;
let num4;
if (num1 > num2) {
num4 = num1;
num1 = num2;
num2 = num4;
}
if (num2 > num3) {
num4 = num2;
num2 = num3;
num3 = num4;
}
if (num1 > num3) {
num4 = num1;
num1 = num3;
num3 = num4;
}
console.log(num1 + `<` + num2 + `<` + num3);

相關文章