Skip to content

Commit 78867a6

Browse files
committed
Commits the changes that I have done.
1 parent fe83039 commit 78867a6

4 files changed

Lines changed: 92 additions & 8 deletions

File tree

01 - JavaScript Drum Kit/index-START.html

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
<link rel="stylesheet" href="style.css">
77
</head>
88
<body>
9-
10-
119
<div class="keys">
1210
<div data-key="65" class="key">
1311
<kbd>A</kbd>
@@ -58,9 +56,27 @@
5856
<audio data-key="76" src="sounds/tink.wav"></audio>
5957

6058
<script>
59+
window.addEventListener('keydown', playSound)
6160

62-
</script>
61+
function playSound(e) {
62+
var audio = document.querySelector('audio[data-key="'+e.keyCode+'"]');
63+
if(!audio) return;
64+
audio.currentTime = 0;
65+
audio.play();
66+
var key = document.querySelector('div[data-key="'+e.keyCode+'"]');
67+
console.log(key);
68+
key.classList.add('playing');
69+
}
6370

71+
var keys = document.querySelectorAll('div.key')
72+
keys.forEach(key => key.addEventListener('transitionend', removeButtonColor))
73+
74+
function removeButtonColor(e) {
75+
if(e.propertyName == 'transform') {
76+
e.target.classList.remove('playing');
77+
}
78+
}
79+
</script>
6480

6581
</body>
6682
</html>

02 - JS + CSS Clock/index-FINISHED.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
top:50%;
6464
transform-origin: 100%;
6565
transform: rotate(90deg);
66-
transition: all 0.05s;
66+
transition: all 0.5s;
6767
transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1);
6868
}
6969
</style>

02 - JS + CSS Clock/index-START.html

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8">
55
<title>JS + CSS Clock</title>
6-
</head>
6+
</head>
77
<body>
88

99

@@ -36,7 +36,7 @@
3636
.clock {
3737
width: 30rem;
3838
height: 30rem;
39-
border:20px solid white;
39+
border:20px solid black;
4040
border-radius:50%;
4141
margin:50px auto;
4242
position: relative;
@@ -58,16 +58,37 @@
5858
.hand {
5959
width:50%;
6060
height:6px;
61-
background:black;
61+
background:white;
6262
position: absolute;
6363
top:50%;
64+
transition: 0.05s;
65+
transform: rotate(90deg);
66+
transform-origin: 100%;
6467
}
6568

6669
</style>
6770

6871
<script>
72+
setInterval(rotateClock, 1000);
6973

74+
function rotateClock() {
75+
var now = new Date();
76+
var seconds = now.getSeconds();
77+
var secondsDegress = ((seconds/60)*360) + 90;
78+
var secondsHand = document.querySelector('div.second-hand');
79+
secondsHand.style.transform = 'rotate('+secondsDegress+'deg)';
7080

81+
var minutes = now.getMinutes();
82+
var minsDegree = ((minutes/60)*360) + 90;
83+
var minsHand = document.querySelector('div.min-hand');
84+
minsHand.style.transform = 'rotate('+minsDegree+'deg)';
85+
86+
var hours = now.getHours();
87+
hours = 21;
88+
var hoursDegree = ((hours/12)*360) + 90;
89+
var hoursHand = document.querySelector('div.hour-hand');
90+
hoursHand.style.transform = 'rotate('+hoursDegree+'deg)';
91+
}
7192
</script>
7293
</body>
7394
</html>

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

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,75 @@
3131

3232
// Array.prototype.filter()
3333
// 1. Filter the list of inventors for those who were born in the 1500's
34+
var filteredInventors = inventors.filter(inventor => (inventor.year >= 1500 && inventor.year < 1600));
35+
console.table(filteredInventors);
3436

3537
// Array.prototype.map()
3638
// 2. Give us an array of the inventors' first and last names
39+
var lastNameArr = inventors.map(function(item) {
40+
return item.first + ' ' + item.last;
41+
});
42+
console.log(lastNameArr);
3743

3844
// Array.prototype.sort()
3945
// 3. Sort the inventors by birthdate, oldest to youngest
46+
var sortedByBirth = inventors.sort(function(a,b) {
47+
if (a.year < b.year) {
48+
return -1;
49+
}
50+
else {
51+
return 1;
52+
}
53+
});
54+
console.table(sortedByBirth);
4055

4156
// Array.prototype.reduce()
4257
// 4. How many years did all the inventors live?
58+
var totalYears = inventors.reduce((total, item) => {
59+
return total + (item.passed - item.year);
60+
},0);
61+
62+
console.log(totalYears);
4363

4464
// 5. Sort the inventors by years lived
65+
var yearsLived = inventors.sort((a,b) => {
66+
ayearslived = a.passed - a.year;
67+
byearslived = b.passed - b.year;
68+
69+
if(ayearslived > byearslived) {
70+
return 1;
71+
}
72+
else {
73+
return -1;
74+
}
75+
});
76+
console.table(yearsLived);
4577

4678
// 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name
4779
// https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris
4880

49-
5081
// 7. sort Exercise
5182
// Sort the people alphabetically by last name
83+
var sortedByLastName = people.sort((a,b) => {
84+
var [aLast, aFirst] = a.split(', ');
85+
var [bLast, bFirst] = b.split(', ');
86+
87+
return aLast > bLast ? 1 : -1;
88+
});
89+
console.log(sortedByLastName);
5290

5391
// 8. Reduce Exercise
5492
// Sum up the instances of each of these
5593
const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ];
94+
var tojo = data.reduce((obj, item) => {
95+
if(!obj[item]) {
96+
obj[item] = 0;
97+
}
98+
obj[item]++;
99+
100+
return obj;
101+
},{});
102+
console.log(tojo);
56103

57104
</script>
58105
</body>

0 commit comments

Comments
 (0)