1const myArray = [{x:100}, {x:200}, {x:300}];
2
3const newArray= myArray.map(element => element.x);
4console.log(newArray); // [100, 200, 300]
1const people = [ {name: "john", age:23},
2 {name: "john", age:43},
3 {name: "jim", age:101},
4 {name: "bob", age:67} ];
5
6const john = people.find(person => person.name === 'john');
7console.log(john);
1const myArray = [{x:100}, {x:200}, {x:300}];
2
3const sum = myArray.map(element => element.x).reduce((a, b) => a + b, 0);
4console.log(sum); // 600 = 0 + 100 + 200 + 300
5
6const average = sum / myArray.length;
7console.log(average); // 200
1const people = [
2 {name: 'John', age: 23},
3 {name: 'Andrew', age: 3},
4 {name: 'Peter', age: 8},
5 {name: 'Hanna', age: 14},
6 {name: 'Adam', age: 37}];
7
8const anyAdult = people.some(person => person.age >= 18);
9console.log(anyAdult); // true
1const people = [
2 { name: "John", age: 21 },
3 { name: "Peter", age: 31 },
4 { name: "Andrew", age: 29 },
5 { name: "Thomas", age: 25 }
6];
7
8let sortByAge = people.sort(function (p1, p2) {
9 return p1.age - p2.age;
10});
11
12console.log(sortByAge);