Cant find the solution when sorting an array in JavaScript

后端 未结 1 2012
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-26 02:27

Hi guys I can\'t figure out why this code doesn\'t work. Could you please shed some light on? I create an array and try to sort it and then display the content on the page. if I

相关标签:
1条回答
  • 2021-01-26 03:10

    How about :

    arr.sort(function(a, b) {
        return a - b;
    });
    

    to do the sort() ?

    0 讨论(0)
提交回复
热议问题