1+ // Массивы
2+ const cars = [ 'Mazda' , 'Ford' , 'BMW' , 'Mersedes' ]
3+ // const people = [
4+ // {name: 'Sergey', budget: 3500},
5+ // {name: 'Victoria', budget: 3200},
6+ // {name: 'Elizabeth', budget: 1500},
7+ // ]
8+ const fib = [ 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 ]
9+ // console.log(cars)
10+
11+ // Function
12+ // function addItemToEnd() {
13+
14+ // }
15+
16+ // Method
17+ // cars.push('Hyundai')
18+ // console.log(cars)
19+
20+ // cars.unshift('Lada')
21+ // console.log(cars)
22+
23+ // const firstItem = cars.shift()
24+ // const lastItem = cars.pop()
25+ // console.log(firstItem)
26+ // console.log(lastItem)
27+ // console.log(cars)
28+
29+ // console.log(cars.reverse())
30+
31+ // const index = cars.indexOf('BMW')
32+ // cars[index] = 'Audi'
33+ // console.log(cars)
34+ // let foundedPerson
35+ // for (const person of people) {
36+ // if (person.budget === 3500) {
37+ // foundedPerson = person
38+ // }
39+ // }
40+
41+ // console.log(foundedPerson)
42+
43+ // const index = people.findIndex(function(person) {
44+ // return person.budget === 3500
45+ // })
46+ // console.log(people[index])
47+ // const person = people.find(function(person) {
48+ // return person.budget === 35002
49+ // })
50+ // console.log(person)
51+
52+ // const person = people.find(person => person.budget === 3500)
53+ // console.log(person)
54+
55+ // console.log(cars.includes('Mazda'))
56+
57+ // const upperCaseCars = cars.map(car => {
58+ // return car.toUpperCase()
59+ // })
60+
61+ const pow2 = num => num ** 2
62+ // const sqrt = num => Math.sqrt(num)
63+
64+ // const pow2Fib = fib.map(pow2).map(Math.sqrt)
65+ // console.log(pow2Fib)
66+ // const pow2Fib = fib.map(pow2)
67+ // const filteredNumbers = pow2Fib.filter(num => num > 20)
68+ // console.log(pow2Fib)
69+ // console.log(filteredNumbers)
70+
71+
72+
73+ // Задача 1
74+ // const text = 'Я долбаеб и мы учимся в юургу'
75+ // const reverseText = text.split('')
76+ // console.log(reverseText)
77+ // console.log(reverseText.reverse().join(''))
78+
79+ const people = [
80+ { name : 'Sergey' , budget : 3500 } ,
81+ { name : 'Victoria' , budget : 3200 } ,
82+ { name : 'Elizabeth' , budget : 1500 } ,
83+ ]
84+
85+ const allBudget = people
86+ . filter ( person => person . budget > 2000 )
87+ . reduce ( ( acc , person ) => {
88+ acc += person . budget
89+ return acc
90+ } , 0 )
91+
92+ console . log ( allBudget )
0 commit comments