Skip to content

Commit b72f2a4

Browse files
committed
changed function
1 parent 61b13da commit b72f2a4

File tree

6 files changed

+61
-227
lines changed

6 files changed

+61
-227
lines changed

01 - JavaScript Drum Kit/index-FINISHED.html

Lines changed: 0 additions & 83 deletions
This file was deleted.

01 - JavaScript Drum Kit/index-START.html

Lines changed: 0 additions & 66 deletions
This file was deleted.

01 - JavaScript Drum Kit/index.html

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,35 +47,26 @@
4747
</div>
4848
</div>
4949

50-
<audio data-key="65" src="sounds/clap.wav"></audio>
51-
<audio data-key="83" src="sounds/hihat.wav"></audio>
52-
<audio data-key="68" src="sounds/kick.wav"></audio>
53-
<audio data-key="70" src="sounds/openhat.wav"></audio>
54-
<audio data-key="71" src="sounds/boom.wav"></audio>
55-
<audio data-key="72" src="sounds/ride.wav"></audio>
56-
<audio data-key="74" src="sounds/snare.wav"></audio>
57-
<audio data-key="75" src="sounds/tom.wav"></audio>
58-
<audio data-key="76" src="sounds/tink.wav"></audio>
50+
<audio data-key="1" src="sounds/clap.wav"></audio>
51+
<audio data-key="2" src="sounds/hihat.wav"></audio>
52+
<audio data-key="3" src="sounds/kick.wav"></audio>
53+
<audio data-key="4" src="sounds/openhat.wav"></audio>
54+
<audio data-key="5" src="sounds/boom.wav"></audio>
55+
<audio data-key="6" src="sounds/ride.wav"></audio>
56+
<audio data-key="7" src="sounds/snare.wav"></audio>
57+
<audio data-key="8" src="sounds/tom.wav"></audio>
58+
<audio data-key="9" src="sounds/tink.wav"></audio>
5959

6060
<script>
6161

6262

6363
function playSound(e) {
64-
const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`);
65-
const key = document.querySelector(`.key[data-key="${e.keyCode}"]`);
66-
if (!audio) return; // stop the fucntion from running all together
64+
const audio = document.querySelector(`audio[data-key="${Math.floor(Math.random()*9)}"]`); // stop the fucntion from running all together
6765
audio.currentTime = 0; // rewind to the start
6866
audio.play();
69-
key.classList.add('playing');
70-
}
71-
function removeTransition(e) {
72-
if (e.propertyName !== 'transform') return; // skip it if it's not a transform
73-
this.classList.remove('playing');
7467
}
7568

76-
const keys = document.querySelectorAll('.key');
77-
keys.forEach(key => key.addEventListener('transitionend', removeTransition));
78-
window.addEventListener('keydown', playSound);
69+
7970

8071
</script>
8172

01 - JavaScript Drum Kit/style.css

Lines changed: 0 additions & 50 deletions
This file was deleted.

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,32 @@
6161
background:black;
6262
position: absolute;
6363
top:50%;
64+
transform-origin: 100%;
65+
transform: rotate(90deg);
66+
transition: all 0.0 5s;
67+
transition-timing-function: cubic-bezier(0.6, -0.28, 0.74, 0.05);
68+
}
6469
}
6570

6671
</style>
6772

6873
<script>
69-
70-
74+
const secondHand = document.querySelector('.second-hand');
75+
const minuteHand = document.querySelector('.min-hand');
76+
const hourHand = document.querySelector('.hour-hand');
77+
function setDate() {
78+
const now = new Date();
79+
const seconds = now.getSeconds();
80+
const minutes = now.getMinutes();
81+
const hours = now.getHours();
82+
console.log(hours);
83+
const secondDegrees = ((seconds/60) * 360) + 90;
84+
const minuteDegrees = ((minutes/60) * 360) + 90;
85+
const hourDegress = ((minutes/12)* 360) + 90;
86+
secondHand.style.transform = `rotate(${secondDegrees}deg)`
87+
minuteHand.style.transform = `rotate(${minuteDegrees}deg)`
88+
}
89+
setInterval(setDate, 1000);
7190
</script>
7291
</body>
7392
</html>

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

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,52 @@
2727

2828
// Array.prototype.filter()
2929
// 1. Filter the list of inventors for those who were born in the 1500's
30-
30+
const fifteen = inventors.filter((inventor) => inventor.year > 1500 && inventor.year < 1600)
3131
// Array.prototype.map()
3232
// 2. Give us an array of the inventory first and last names
33-
33+
const names = inventors.map((inventor)=> `${inventor.first} ${inventor.last}`);
3434
// Array.prototype.sort()
3535
// 3. Sort the inventors by birthdate, oldest to youngest
36-
36+
const sortBirth = inventors.sort((a,b)=> a.year > b.year ? 1 : -1);
37+
console.log(sortBirth);
3738
// Array.prototype.reduce()
3839
// 4. How many years did all the inventors live?
39-
40+
totalYears = inventors.reduce((total, inventor) => total + (inventor.passed - inventor.year), 0);
41+
console.log(totalYears);
4042
// 5. Sort the inventors by years lived
41-
43+
const sortYears = inventors.sort((a,b) => (a.passed - a.year) > (b.passed - b.year) ? 1: -1);
44+
console.table(sortYears);
4245
// 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name
4346
// https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris
47+
// const category = document.querySelector('.mw-category');
4448

49+
// const links = category.querySelectorAll('a');
50+
51+
// const array = Array.from(links);
52+
53+
// let de = array.filter((item) => item.textContent.includes('de'));
4554

4655
// 7. sort Exercise
4756
// Sort the people alphabetically by last name
4857

58+
59+
let alpha = people.sort(function(lastOne, nextOne){
60+
let part1 = lastOne.split(', ')[0];
61+
let part2 = nextOne.split(', ')[0];
62+
return part1 > part2 ? 1 : -1;
63+
64+
});
4965
// 8. Reduce Exercise
5066
// Sum up the instances of each of these
5167
const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ];
52-
68+
listObject = data.reduce((obj, item)=>{
69+
if(!obj[item]) {
70+
obj[item] = 0;
71+
}
72+
obj[item]++;
73+
return obj;
74+
}, {});
75+
console.log(listObject);
5376
</script>
5477
</body>
5578
</html>

0 commit comments

Comments
 (0)