-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path05_array.js
More file actions
105 lines (93 loc) · 2.63 KB
/
05_array.js
File metadata and controls
105 lines (93 loc) · 2.63 KB
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
101
102
103
104
105
//1 Массивы
// const cars =['Мазда','Форд','БМВ','Мерседес']//Задание в консоли через new Array
// const fib =[1,1,2,3,5,8,13]
// const people = [
// {name: 'Даниил' , money: 5000},
// {name: 'Никита' , money: 1000},
// {name: 'Саша' , money: 2000}
// ]
//Function
// function addItemToEnd(){
//
// }
//Method
// cars.push('Рено')
//
// console.log(cars);
//
// cars.unshift('Волга')
// console.log(cars);
//
// const firstItem = cars.shift()
// const lastItem = cars.pop()
// console.log(firstItem);
// console.log(lastItem);
// console.log(cars);
// console.log(cars.reverse());
// console.log(cars);
// const index = cars.findIndex('БМВ')
// cars[index] = 'Порш'
// console.log(cars);
// const index = people.findIndex(function(person) {
// return person.money === 5000
//
// })
// const person = people.find(function(person) {
// return person.money === 5000
//
// })
// console.log(person);
//////////////////////////////////////////////////////////////////////
//Задача 1(Переворачивание текста)
// const text = 'Привет, я изучаю JavaScript'
// const reverseText = text.split('').reverse().join(' ')
// console.log(reverseText);
//////////////////////////////////////////////////////////////////////
// let findedPerson
// for (const person of people){
// if (person.money === 5000){
// findedPerson = person
// }
// }
// console.log(findedPerson);
// const person = people.find(person => person.money ===5000)
// console.log(person);
// const mazda = cars.includes('Мазда')
// console.log(mazda);
// const upperCaseCars = cars.map(car =>{
// return car.toUpperCase()
// })
// console.log(upperCaseCars);
//
// const pow2 = num => num**2
// const sqrt = num => Math.sqrt(num)
//
//
// const pow2Fib = fib.map(pow2).map(sqrt)
// console.log(pow2Fib);
// const pow2 = num => num**2
// const pow2Fib = fib.map(pow2)
// const filteredNumbers = pow2Fib.filter(num => {
// return num > 20
// })
// console.log(pow2Fib);
// console.log(filteredNumbers);
// const people = [
// {name: 'Даниил' , money: 5000},
// {name: 'Никита' , money: 1000},
// {name: 'Саша' , money: 2000}
// ]
// const allMoney = people.reduce(function(acc, person) {
// if (person.money>1000){
// acc+=person.money
// }
// return(acc)
// }, 0)
// console.log(allMoney);
// const allMoney = people
// .filter(person => person.money > 1000)
// .reduce((acc, person) => {
// acc+=person.money
// return acc
// }, 0)
// console.log(allMoney);