Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Array/array-oprtions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const points = ["Banana", "Orange", "Coconut", "Mango"];

//sort an array in descending order
points.sort();

//reverse the array
points.reverse();


const num1 = [11, 2, 32, 5, 12];

//Creates a new array by performing a function on each array element
const num2 = numbers1.map(myFunction);
function myFunction(value, index, array) {
return value * 4;
}

//Creates a new array with all array elements that passes a test
const num3 = num1.filter(myFunction);
function myFunction(value, index, array) {
return value > 19;
}

//The every() method checks if all array values pass a test
let all1 = num1.every(myFunction);

function myFunction(value) {
return value > 11;
}

//The some() method checks if some array values pass a test
let all2 = numbers.some(myFunction);

function myFunction(value, index, array) {
return value > 13;
}