-
Notifications
You must be signed in to change notification settings - Fork 0
/
5.array.js
65 lines (53 loc) · 1.65 KB
/
5.array.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
// Массивы
const languages = ['Python', 'JavaScript', 'C', 'C++', 'Pascal']
const users = [
{name: 'userName1', age: 10, createdAt: new Date()},
{name: 'userName2', age: 25, createdAt: new Date()},
{name: 'userName3', age: 42, createdAt: new Date()}
]
const functions = [() => {}, () => {}]
const numbers = [1, 2, 3, 4, 5, 6, 7, 8]
// console.log(languages[4])
// console.log(languages.length)
// languages.push('C#')
// console.log(languages)
// languages.unshift('Java')
// console.log(languages)
// const first = languages.shift()
// const last = languages.pop()
// console.log(first)
// console.log(last)
// console.log(numbers.reverse())
// console.log(numbers)
// console.log(languages.indexOf('C++'))
// console.log(languages.indexOf('C+'))
// const index = languages.indexOf('C')
// console.log(languages[index].firstName)
// const findedUserIndex = users.findIndex(function(user) {
// return user.age === 25
// })
// console.log(findedUserIndex)
// const findedUser = users.find(function(user) {
// return user.age === 25
// })
// console.log(findedUser)
// const findedUser = users.find((user) => user.age === 25)
// console.log(findedUser)
// const checkAge = (age) => (user) => user.age === age
//
// const findedUser = users.find(checkAge(25))
// console.log(findedUser)
// const newUsers = users.map(user => {
// user.year = 2021 - user.age
// return user
// })
// console.log(newUsers)
// console.log(languages.includes('C++'))
// const sumAge = users
// .filter(user => user.age > 18)
// .map(user => {
// user.year = 2021 - user.age
// return user
// })
// .reduce((acc, user) => acc + user.year, 0)
// console.log(sumAge)