Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cae6e7f

Browse files
Merge pull request #13 from vedang-eng/main
array-oprtions.js
2 parents 4fc96ad + 22b8759 commit cae6e7f

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

‎Array/array-oprtions.js‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const points = ["Banana", "Orange", "Coconut", "Mango"];
2+
3+
//sort an array in descending order
4+
points.sort();
5+
6+
//reverse the array
7+
points.reverse();
8+
9+
10+
const num1 = [11, 2, 32, 5, 12];
11+
12+
//Creates a new array by performing a function on each array element
13+
const num2 = numbers1.map(myFunction);
14+
function myFunction(value, index, array) {
15+
return value * 4;
16+
}
17+
18+
//Creates a new array with all array elements that passes a test
19+
const num3 = num1.filter(myFunction);
20+
function myFunction(value, index, array) {
21+
return value > 19;
22+
}
23+
24+
//The every() method checks if all array values pass a test
25+
let all1 = num1.every(myFunction);
26+
27+
function myFunction(value) {
28+
return value > 11;
29+
}
30+
31+
//The some() method checks if some array values pass a test
32+
let all2 = numbers.some(myFunction);
33+
34+
function myFunction(value, index, array) {
35+
return value > 13;
36+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /