Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lesson 1: Drumkit - Playing multiple audios at once causes overlapping #660

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
24d1492
Add drumkit audios overlap issue fix
ItsNamrathaB Apr 14, 2024
6d6ef12
Add Lesson 2 and 3 practice versions
ItsNamrathaB Apr 16, 2024
d2d3eef
Add Lesson 4 practice version
ItsNamrathaB Apr 17, 2024
f5a2453
Add Lesson 5 practice version
ItsNamrathaB Apr 18, 2024
d09d867
Add Lesson 5 practice version
ItsNamrathaB Apr 20, 2024
a806310
Add Lesson 6 practice version
ItsNamrathaB Apr 20, 2024
4f1a905
Add Lesson 7 practice version
ItsNamrathaB Apr 20, 2024
f50b8dd
Add Lesson 8 practice version
ItsNamrathaB Apr 21, 2024
5c37a87
Add Lesson 9 practice version
ItsNamrathaB Apr 22, 2024
9c6e03b
Add Lesson 10 practice version
ItsNamrathaB Apr 23, 2024
66e1f09
Add Lesson 11 practice version
ItsNamrathaB May 1, 2024
f52cc63
Add Lesson 12 practice version
ItsNamrathaB May 2, 2024
55c14a2
Add Lesson 13 practice version
ItsNamrathaB May 3, 2024
51b6a82
Add Lesson 14 practice version
ItsNamrathaB May 3, 2024
e8fa757
Add Lesson 15 practice version
ItsNamrathaB May 6, 2024
22c539e
Add Lesson 16 practice version
ItsNamrathaB May 6, 2024
8754574
Add Lesson 17 practice version
ItsNamrathaB May 6, 2024
37cf511
Add Lesson 16 practice version
ItsNamrathaB May 6, 2024
9d0ef70
Add Lesson 15 practice version
ItsNamrathaB May 6, 2024
81f8c67
Add Lesson 18 practice version
ItsNamrathaB May 7, 2024
0954d52
Add Lesson 19 practice version(till capture)
ItsNamrathaB May 8, 2024
de81d29
Add Lesson 20 practice version
ItsNamrathaB May 8, 2024
9e0c83e
Add Lesson 22 practice version
ItsNamrathaB May 9, 2024
0ca698b
Add Lesson 24 practice version
ItsNamrathaB May 9, 2024
0abaaa6
Add Lesson 25 practice version
ItsNamrathaB May 10, 2024
ea6998f
Add Lesson 26 practice version
ItsNamrathaB May 19, 2024
97678a5
Add Lesson 27 practice version
ItsNamrathaB May 19, 2024
16a5847
Add Lesson 28 practice version
ItsNamrathaB May 19, 2024
88d31e6
Add Lesson 29 practice version
ItsNamrathaB May 21, 2024
164632c
Add Lesson 30 practice version
ItsNamrathaB May 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion 01 - JavaScript Drum Kit/index-FINISHED.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
<audio data-key="76" src="sounds/tink.wav"></audio>

<script>

let currentAudio = null;

function removeTransition(e) {
if (e.propertyName !== 'transform') return;
e.target.classList.remove('playing');
Expand All @@ -67,10 +70,16 @@
function playSound(e) {
const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`);
const key = document.querySelector(`div[data-key="${e.keyCode}"]`);

if(currentAudio && !currentAudio.paused){
currentAudio.pause();
currentAudio.currentTime = 0;
}

if (!audio) return;

key.classList.add('playing');
audio.currentTime = 0;
currentAudio = audio;
audio.play();
}

Expand Down
104 changes: 104 additions & 0 deletions 02 - JS and CSS Clock/index-PRACTICE.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JS + CSS Clock</title>
<link rel="icon" href="https://fav.farm/🔥" />
</head>
<body>


<div class="clock">
<div class="clock-face">
<div class="hand hour-hand"></div>
<div class="hand min-hand"></div>
<div class="hand second-hand"></div>
</div>
</div>


<style>
html {
background: #018DED url(https://unsplash.it/1500/1000?image=881&blur=5);
background-size: cover;
font-family: 'helvetica neue';
text-align: center;
font-size: 10px;
}

body {
margin: 0;
font-size: 2rem;
display: flex;
flex: 1;
min-height: 100vh;
align-items: center;
}

.clock {
width: 30rem;
height: 30rem;
border: 20px solid white;
border-radius: 50%;
margin: 50px auto;
position: relative;
padding: 2rem;
box-shadow:
0 0 0 4px rgba(0,0,0,0.1),
inset 0 0 0 3px #EFEFEF,
inset 0 0 10px black,
0 0 10px rgba(0,0,0,0.2);
}

.clock-face {
position: relative;
width: 100%;
height: 100%;
transform: translateY(-3px); /* account for the height of the clock hands */
}

.hand {
width: 50%;
height: 6px;
background: black;
position: absolute;
top: 50%;
transform-origin: 100%;
transform: rotate(90deg);
transition: all 0.05s;
transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1);
}

.second-hand {
background: pink;
}

</style>

<script>
const secondsHand = document.querySelector('.second-hand');
const minutesHand = document.querySelector('.min-hand');
const hoursHand = document.querySelector('.hour-hand');

function setDate(){
const now = new Date();

const seconds = now.getSeconds();
const secondsDegrees = ((seconds / 60) * 360) + 90;
secondsHand.style.transform = `rotate(${secondsDegrees}deg)`;

const minutes = now.getMinutes();
const minutesDegrees = ((minutes / 60) * 360) + 90;
minutesHand.style.transform = `rotate(${minutesDegrees}deg)`;

const hours = now.getHours();
const hoursDegrees = ((hours / 12) * 360) + ((minutes/60)*30) + 90;
hoursHand.style.transform = `rotate(${hoursDegrees}deg)`;
}

setInterval(setDate, 1000);

setDate();
</script>
</body>
</html>
76 changes: 76 additions & 0 deletions 03 - CSS Variables/index-PRACTICE.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Scoped CSS Variables and JS</title>
<link rel="icon" href="https://fav.farm/🔥" />
</head>
<body>
<h2>Update CSS Variables with <span class='h1'>JS</span></h2>

<div class="controls">
<label for="spacing">Spacing:</label>
<input id="spacing" type="range" name="spacing" min="10" max="200" value="10" data-sizing="px">

<label for="blur">Blur:</label>
<input id="blur" type="range" name="blur" min="0" max="25" value="10" data-sizing="px">

<label for="base">Base Color</label>
<input id="base" type="color" name="base" value="#ffc600">
</div>

<img src="https://source.unsplash.com/7bwQXzbF6KE/800x500">

<style>
:root {
--base: #ffc600;
--spacing: 10px;
--blur: 10px;
}

img{
padding: var(--spacing);
background: var(--base);
filter: blur(var(--blur));
}

.h1{
color: var(--base);
}

/*
misc styles, nothing to do with CSS variables
*/

body {
text-align: center;
background: #193549;
color: white;
font-family: 'helvetica neue', sans-serif;
font-weight: 100;
font-size: 50px;
}

.controls {
margin-bottom: 50px;
}

input {
width: 100px;
}
</style>

<script>
const inputs = document.querySelectorAll(".controls input");

function handleUpdate(){
const suffix = this.dataset.sizing || '';
document.documentElement.style.setProperty(`--${this.name}`, this.value + suffix);
}

inputs.forEach((input) => input.addEventListener("change", handleUpdate));
inputs.forEach((input) => input.addEventListener("mousemove", handleUpdate));
</script>

</body>
</html>
109 changes: 109 additions & 0 deletions 04 - Array Cardio Day 1/index-PRACTICE.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Array Cardio 💪</title>
<link rel="icon" href="https://fav.farm/🔥" />
</head>
<body>
<p><em>Psst: have a look at the JavaScript Console</em> 💁</p>
<script>
// Get your shorts on - this is an array workout!
// ## Array Cardio Day 1

// Some data we can work with

const inventors = [
{ first: 'Albert', last: 'Einstein', year: 1879, passed: 1955 },
{ first: 'Isaac', last: 'Newton', year: 1643, passed: 1727 },
{ first: 'Galileo', last: 'Galilei', year: 1564, passed: 1642 },
{ first: 'Marie', last: 'Curie', year: 1867, passed: 1934 },
{ first: 'Johannes', last: 'Kepler', year: 1571, passed: 1630 },
{ first: 'Nicolaus', last: 'Copernicus', year: 1473, passed: 1543 },
{ first: 'Max', last: 'Planck', year: 1858, passed: 1947 },
{ first: 'Katherine', last: 'Blodgett', year: 1898, passed: 1979 },
{ first: 'Ada', last: 'Lovelace', year: 1815, passed: 1852 },
{ first: 'Sarah E.', last: 'Goode', year: 1855, passed: 1905 },
{ first: 'Lise', last: 'Meitner', year: 1878, passed: 1968 },
{ first: 'Hanna', last: 'Hammarström', year: 1829, passed: 1909 }
];

const people = [
'Bernhard, Sandra', 'Bethea, Erin', 'Becker, Carl', 'Bentsen, Lloyd', 'Beckett, Samuel', 'Blake, William', 'Berger, Ric', 'Beddoes, Mick', 'Beethoven, Ludwig',
'Belloc, Hilaire', 'Begin, Menachem', 'Bellow, Saul', 'Benchley, Robert', 'Blair, Robert', 'Benenson, Peter', 'Benjamin, Walter', 'Berlin, Irving',
'Benn, Tony', 'Benson, Leana', 'Bent, Silas', 'Berle, Milton', 'Berry, Halle', 'Biko, Steve', 'Beck, Glenn', 'Bergman, Ingmar', 'Black, Elk', 'Berio, Luciano',
'Berne, Eric', 'Berra, Yogi', 'Berry, Wendell', 'Bevan, Aneurin', 'Ben-Gurion, David', 'Bevel, Ken', 'Biden, Joseph', 'Bennington, Chester', 'Bierce, Ambrose',
'Billings, Josh', 'Birrell, Augustine', 'Blair, Tony', 'Beecher, Henry', 'Biondo, Frank'
];

// Array.prototype.filter()
// 1. Filter the list of inventors for those who were born in the 1500's
const fifteenHundreds = inventors.filter(inventor => (inventor.year >=1500 && inventor.year<1600));
console.table(fifteenHundreds);

// Array.prototype.map()
// 2. Give us an array of the inventors first and last names
const firstAndLastNames = inventors.map(inventor => inventor.first+" "+inventor.last);
console.table(firstAndLastNames);

// Array.prototype.sort()
// 3. Sort the inventors by birthdate, oldest to youngest
const sortedByBD = inventors.sort((first, second) => first.year > second.year ? 1: -1);
console.table(sortedByBD);

// Array.prototype.reduce()
// 4. How many years did all the inventors live all together?
const totalYearsLivedByAll = inventors.reduce((total, inventor) => total + (inventor.passed - inventor.year), 0);
console.log(totalYearsLivedByAll);

// 5. Sort the inventors by years lived
const sortedByYearsLived = inventors.sort((first,second) => ((first.passed - first.year) < (second.passed - second.year)) ? 1 : -1);
console.table(sortedByYearsLived);

// 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name
// https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris
// const parent = document.querySelector('.mw-category');
// const links = Array.from(parent.querySelectorAll('a'));
// const names = links.map(link => link.title);
// const deNames = names.filter(name => name.includes('de'));
// console.log(deNames);

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

// Bruteforce(aka dumb) solution
// const sortedByLastName = people.sort((first,second) => {
// const firstSplit = first.split(',');
// const nextFirstSplit = firstSplit[1].split(' ');
// const firstLastName = nextFirstSplit[1];

// const secondSplit = second.split(',');
// const nextSecondSplit = secondSplit[1].split(' ');
// const secondLastName = nextSecondSplit[1];

// return (firstLastName > secondLastName) ? 1 : -1;
// })

// better solution
const sortedByLastName = people.sort((first,second) => first.split(', ')[0] > second.split(', ')[0] ? 1 : -1);
console.table(sortedByLastName);

// 8. Reduce Exercise
// Sum up the instances of each of these
const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ];
// const counts = data.reduce((accumulator, current) => {
// accumulator[current] = (accumulator.hasOwnProperty(current) ? (accumulator[current] + 1) : 1);
// return accumulator;
// }, {})

const counts = data.reduce((accumulator, current) =>{
if(!accumulator.hasOwnProperty(current))
accumulator[current] = 0;
accumulator[current]++;
return accumulator;
}, {})
console.log(counts);

</script>
</body>
</html>
Loading