Answers for "how to return ascending array using for loop in js"

0

how to return ascending array using for loop in js

var Arr = [1, 7, 2, 8, 3, 4, 5, 0, 9];

for (var i = 1; i < Arr.length; i++)
    for (var j = 0; j < i; j++)
        if (Arr[i] < Arr[j]) {
          var x = Arr[i];
          Arr[i] = Arr[j];
          Arr[j] = x;
        }

console.log(Arr);
Posted by: Guest on January-21-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language