Skip to content

Commit 91bbe7c

Browse files
author
Harshavardhan Boddupally
committed
completed wesbos#4
1 parent aff5345 commit 91bbe7c

File tree

4 files changed

+56
-23
lines changed

4 files changed

+56
-23
lines changed

04 - Array Cardio Day 1/CustomHigherOrder.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ function myownmap(arr, fn) {
1414
});
1515
return newArray;
1616
}
17-
console.log(arr2);
18-
console.log(arr3);
17+
//console.log(arr2);
18+
//console.log(arr3);
1919

2020
/*Our own version of array filter*/
2121
const arr4 = [1, 2, 3,4,5,6,7,8];
@@ -29,6 +29,6 @@ function myownfilter(arr, fn) {
2929
});
3030
return newArray;
3131
}
32-
console.log(arr5);
33-
console.log('custom');
34-
console.log(arr6);
32+
//console.log(arr5);
33+
//console.log('custom');
34+
//console.log(arr6);

04 - Array Cardio Day 1/index-FINISHED.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@
8989

9090
// 8. Reduce Exercise
9191
// Sum up the instances of each of these
92-
const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck', 'pogostick'];
92+
const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van',
93+
'bike', 'walk', 'car', 'van', 'car', 'truck', 'pogostick'];
9394

9495
const transportation = data.reduce(function(obj, item) {
9596
if (!obj[item]) {

04 - Array Cardio Day 1/index-START.html

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,33 +35,38 @@
3535
// Array.prototype.map()
3636
// 2. Give us an array of the inventors first and last names
3737
const inventornames = inventors.map(element => `${element.first} ${element.last}`);
38-
console.log(inventornames);
38+
const tryMaps = inventors.map(function(element,index,array){
39+
console.log(element);
40+
console.log(index);
41+
console.log(array);
42+
})
43+
// console.log(inventornames);
3944

4045
// Array.prototype.sort()
4146
// 3. Sort the inventors by birthdate, oldest to youngest
4247
const inventorAges = inventors.sort((a,b) => (a.year - b.year));
43-
console.log('ages');
44-
console.log(inventorAges);
48+
// console.log('ages');
49+
// console.log(inventorAges);
4550

4651
// Array.prototype.reduce()
4752
// 4. How many years did all the inventors live all together?
4853
const ageCombined_func = (accumulator, currentValue) => accumulator + (currentValue.passed-currentValue.year);
4954
const ageCombined = inventors.reduce(ageCombined_func,0);
50-
console.log('ages combined');
51-
console.log(ageCombined);
55+
//console.log('ages combined');
56+
//console.log(ageCombined);
5257

5358
// 5. Sort the inventors by years lived
5459
const inventorOld = inventors.sort((a,b) => ((a.year-a.passed) - (b.year-b.passed)));
55-
console.log('old');
56-
console.log(inventorOld);
60+
//console.log('old');
61+
//console.log(inventorOld);
5762

5863
// 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name
5964
// https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris
6065
let getAllAnchors = document.querySelectorAll('.mw-category-group > ul > li > a');
6166
let allNames =[];
6267
getAllAnchors.forEach((a) => allNames.push((a.title)));
6368
let allFilteredNames = allNames.filter(element => element.includes('de'));
64-
console.log(allFilteredNames);
69+
//console.log(allFilteredNames);
6570

6671
// 7. sort Exercise
6772
// Sort the people alphabetically by last name
@@ -75,19 +80,19 @@
7580
// a must be equal to b
7681
return 0;
7782
});
78-
console.log('names');
79-
console.log(peopleName);
83+
// console.log('names');
84+
// console.log(peopleName);
8085

8186
// 8. Reduce Exercise
8287
// Sum up the instances of each of these
8388
const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ];
84-
// const result = [];
85-
// const instance_func = function(accumulator, currentValue){
86-
// if(data.filter((element) => element === currentValue))
87-
// };
88-
// const ageCombined = inventors.reduce(ageCombined_func,0);
89-
// console.log('ages combined');
90-
// console.log(ageCombined);
89+
const transportation = data.reduce(function(obj, item) {
90+
if (!obj[item]) {
91+
obj[item] = 0;
92+
}
93+
obj[item]++;
94+
return obj;
95+
}, {});
9196

9297
</script>
9398
<script src="CustomHigherOrder.js"></script>

05 - Flex Panel Gallery/index-START.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
.panels {
2727
min-height: 100vh;
2828
overflow: hidden;
29+
display: flex;
30+
justify-content: space-between;
2931
}
3032

3133
.panel {
@@ -43,6 +45,10 @@
4345
font-size: 20px;
4446
background-size: cover;
4547
background-position: center;
48+
flex-grow: 1;
49+
display: flex;
50+
flex-direction: column;
51+
justify-content: center;
4652
}
4753

4854
.panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); }
@@ -69,10 +75,24 @@
6975
font-size: 4em;
7076
}
7177

78+
.panel p:not(:nth-child(2)) {
79+
transform: translateY(-1000%);
80+
transition: transform .5s ease-in;
81+
}
82+
7283
.panel.open {
7384
font-size: 40px;
7485
}
7586

87+
.expandPanel{
88+
flex-grow: 10;
89+
}
90+
91+
.slideIn{
92+
display: block;
93+
transform: translateY(100%);
94+
}
95+
7696
</style>
7797

7898

@@ -105,7 +125,14 @@
105125
</div>
106126

107127
<script>
128+
const getPanel = document.querySelectorAll('.panel');
129+
getPanel.forEach(element => element.addEventListener("click",function(e){
130+
addExpandClass(this);
131+
}))
108132

133+
const addExpandClass = function (e){
134+
e.classList.toggle('expandPanel');
135+
}
109136
</script>
110137

111138

0 commit comments

Comments
 (0)