logo
Search
showing results for - "how to return ascending array using for loop in js"
Reuben
13 Feb 2017
1var Arr = [1, 7, 2, 8, 3, 4, 5, 0, 9];
2
3for (var i = 1; i < Arr.length; i++)
4    for (var j = 0; j < i; j++)
5        if (Arr[i] < Arr[j]) {
6          var x = Arr[i];
7          Arr[i] = Arr[j];
8          Arr[j] = x;
9        }
10
11console.log(Arr);
source
similar questions
sort string mixed with numbers javascriptjavascript loop through aray backwardjs loop array backwardsloop through arrays in es6find largest number in array javascript using for loopjavascript best way to loop through arrayjs loop through associative arrayjavascript sort array in ascending orderhow to sort array least to greatest javascript stackjavascript best way to iterate over arrayloop through an array javascriptloop through an array in javascriptloop array backwards javascripthow to loop through array of numbers in javascriptloop through an array in jssorting array of numbers in javascriptjavascript loop thrugh arraysorting array from highest to lowest javascript
queries leading to this page
sort the array in ascending using for loop in javascriptloop array ascending order in javascriptascending order in javascript for loopsorting array in javascript using for loopsorting using loops javascriptjavascript for loop arrangehow to return ascending array using for loop in js
privacy policyterms of useinstagram
Crafted with  ♥  for everyone

sign in to continue
your answer for
you will get a confirmation link on this - you will have to click that for successful submission of your answer. we require this to keep the website free of spam, bots and unhelpful content
please ensure to add code which is syntactically corrent and executes properly
sign in to continue
ask question on maxinterview
you will get a confirmation link on this - you will have to click that for successful submission of your question. we require this to keep the website free of spam, bots and unhelpful content
please be clear, to the point and respectful
sign in to continue