-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patharrays.js
59 lines (34 loc) · 862 Bytes
/
arrays.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var myArr=[4,"string",function(){console.log('hello')},{name:'ali'}];
var myArr2=new Array(3,4,6,"mahmoud");
console.log(typeof myArr);
myArr[0]=20;
console.log(myArr[0])
console.log(myArr[7]);
console.log(myArr.join(':'));
//adding to the beginning of the array
myArr.unshift('ahmed');
console.log(myArr.join(':'));
myArr.push(true);
console.log(myArr.join(':'));
var removedValue=myArr.pop();
var st="20";
console.log(Number(st))
//
var arr=[2,5,7,8];
var newArr=[];
//functional programming style..
arr.forEach(function(e){
newArr.push(Math.pow(e,2));
if(typeof e==Number){
console.log(e);
}
});
var result=arr.map(function(e){
return Math.pow(e,2);
});
var evenNumbersArr=result.find(function(e){
return e%2==0;
});
console.log(evenNumbersArr);
//console.log(arr.sort().reverse());
//console.log(newArr);