-
Notifications
You must be signed in to change notification settings - Fork 1
/
app3.js
102 lines (70 loc) · 2.09 KB
/
app3.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//const arr = ["ali","reza","hasan","azar"];
// const arrObj = [
// {name:'ali',age:12},
// {name:'reza',age:18},
// {name:'hasan',age:20},
// {name:'azar',age:15}
// ];
// function mysort(a,b){
// if (a.name > b.name) return -1;
// if (a.name < b.name) return 1;
// return 0;
// }
// arrObj.sort(mysort);
// console.log(arrObj);
//const arr = ["ali","reza","hasan","azar"];
// const newArr = arr.map(function (element){
// return ". First Name Is: " + element;
// });
// console.log(newArr);
// const arrObj = [
// {name:'ali',age:12},
// {name:'reza',age:18},
// {name:'hasan',age:20},
// {name:'azar',age:15}
// ];
// let sumAge = 0;
// arrObj.forEach(function(element,index){
// element.age += 2;
// });
// console.log(arrObj);
//console.log(sumAge / arrObj.length);
// const result = arrObj.every(function(element){
// return element.age < 22;
// });
// const result = arrObj.some(function(element){
// return element.age < 10;
// });
// console.log(result);
const arrObj = [
{name:'ali',age:12},
{name:'reza',age:18},
{name:'hasan',age:20},
{name:'hasan',age:23},
{name:'azar',age:15}
];
// const index = arrObj.findIndex(function(element,index){
// return element.name === "hasan";
// });
// console.log(index);
// arrObj[index].age -=2;
// const element = arrObj.find(function(element,index){
// return element.name === "hasan";
// });
// console.log(element);
// const filtered = arrObj.filter(function(element,index){
// return element.name === "azar";
// });
// const finded = arrObj.find(function(element,index){
// return element.name === "azar";
// });
// console.log(finded);
// console.log(filtered[0]);
// const result = arrObj.reduce(function(prev,current){
// return prev.age + current.age;
// });
// console.log(result);
// const date = new Date(2021,12,3);
// console.log(date.get);
// const pattern = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/g
// console.log(pattern.test("[email protected]"));