The recent beginner JS, think is a very powerful language, early in the console output, a simple summary of the method of array sorting:
First, select the sort and then go to weight:
Let arr = [3,7,2,9,6,5,8,7,3];let temp;for (Let i=0; i<arr.length-1; i++) {for (let J=i+1; j<arr.length; j + +) {
if (Arr[i]>arr[j]) { temp = arr[i]; Arr[i] = arr[j]; ARR[J] = temp;}} } Let arr1 = [];for (let k=0; k<arr.length; k++) { if (arr[k]! = arr[k+1]) { arr1 = Arr1.concat (Arr[k]);} } Console.log (ARR1);
This method is more complex, and the order of the array to be re-ordered will change, so it is only a reference to a thought exercise:
Second, the direct removal of repeated element method to weight:
Let arr = [3,7,2,3,9,6,7,5,8,7];for, let i=0; i<arr.length; i++] {for (let J=i+1; j<arr.length; j + +) { if (AR R[i]==arr[j]) { arr.splice (j,1);}} Console.log (arr);
JS Array console sequencing