Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js method .sort

function eq(x, y) {
  if (x < y) return -1;
  else if (x > y) return 1;
  else return 0;
}

let num = new Array(8, 50, 2, 34, 12, 8);

num.sort(eq);

let text = num.join();

document.write(text);
Source by www.javascripttutorial.net #
 
PREVIOUS NEXT
Tagged: #js #method
ADD COMMENT
Topic
Name
1+5 =