Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

add array and sort

// ادخال قيم الى المصفوفة
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi", "Lemon"); 

//فرز 
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.sort();

const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.sort();
fruits.reverse();

// OR 
// فرز تصاعدي وتنازلي  a=>b b=>a
const points = [40, 100, 1, 5, 25, 10];
points.sort(function(a, b){return a-b});

const points = [40, 100, 1, 5, 25, 10];
points.sort(function(a, b){return b-a});
 
PREVIOUS NEXT
Tagged: #add #array #sort
ADD COMMENT
Topic
Name
5+9 =