30 Day Vanilla JS Coding Challenge from Wes Bos
Day 1: Drum Kit
I am creating a drum kit using Javascript and a bunch of audio files
What I learned:
addEventListener
can listen to a lot of events- Playing audio files is as simple as running
.play()
querySelector
can be used to select a matched element- For every key pressed, there’s a lot of information being passed to the function
classList
returns a list of all classes which can be modified
Day 2: JS and CSS Clock
I am creating a simlpe Clock just using JS and CSS
What I learned:
- I can easily set inline styles using
Element.style
- Transforming an element is, by default, at the center
Element.style.Property = ''
resets the styling
I had already known CSS variables and forEach
in JS.
So, what I learned:
- All of the data attributes can be accessed using
dataset
QuerySelectorAll
returns a NodeList, which is kind of like an Array, except that it’s not- CSS Custom Properties can be changed using the
setProperty
method
Day 4: Array Cardio Day 1
Today we are going to work with Arrays and the different methods that we can use: filter()
, map()
, sort()
, reduce()
.
What I learned:
map()
andsort()
will always return the same number of items- An initial value is very important in the
reduce()
method - How 1 and -1 work in the
sort()
method
Day 5: Flex Panels Image Gallery
We made an image gallery with CSS Flexbox.
What I learned today:
- The
toggle()
method is a cool way to literally toggle classes - Using
includes()
we can check if something has a certain word or character that we are looking for - To make image gallery like on many frontpages of a photographers portfolio it really isn’t hard
Day 6: Type Ahead
In the lesson we are using fetch()
and filter()
methods and also takes advantage of regular expressions to build a simple filter for american cities. Did the same with russian cities in parallel branch
Day 7: Array Cardio Day 2
Today We will explore six JavaScript array functions: some()
, every()
, find()
, findIndex()
, splice()
and slice()
Day 8: Fun with HTML5 Canvas
Today we are going to create a drawing game using the HTML5 canvas element. We will need to:
- Stretch the canvas to fill the window
height
andwidth
. - Set the base settings of the
strokeStyle
,lineJoin
andlineCap
. - Set default drawing variables (to control so the drawing only happens when the mouse is down - not just when the mouse moves).
- Set default variables to hold the beginning and ending coordinates for drawing lines.
- Create some event listeners and a function to handle drawing.
- Add a rainbow styled stroke (first initialising
hue
and then setting thestrokeStyle
to an hsl colour)
Today we're learning 14 Must know Dev tools tricks:
- Inspect the element in the dev tools (
Break on... > attribute modifications
) console.log()
- Interpolate (use
%s
) - Styled Console Logging (add
%c
at the beginning of the message) - Warnings in the Console (use
console.warn()
) - Errors in the Console (use
console.error()
) - Information in the Console (use
console.info()
) - Using
console.assert()
for Testing - Clearing the Console (use
console.clear()
) - View DOM Elements (use
console.dir()
) - Grouping Together (use
console.group(name)
andconsole.groupEnd(name)
) - Counting Instances (use
console.count()
) - Timing (use
console.time()
andconsole.timeEnd()
) - Log in a table (use
console.table()
)