js编写函数功能是将三个数按照从小到大顺序输出

编写函数功能是将三个数按照从小到大顺序输出
function fnSort(a,b,c){
        //假设aa>b a>c b>c 然后进行交换即可
        var t =0
        if(a>b){
            t = a;
            a = b;
            b = t       
        }
        if(a > c){
            t = a;
            a = c;
            c = t;
        }
        if(b > c){
            t = b;
            b = c;
            c = t;      
        }
        document.write( "这三个数按照从小到大的顺序输出是:"+ a + "<" + b + "<" + c +"
"
); } fnSort(2,9,4); fnSort(4,2,9); fnSort(9,4,2);

你可能感兴趣的:(js编写函数功能是将三个数按照从小到大顺序输出)