Wes Bos Beginner JS Course

Notes from the course

I’ve noticed that Wes Bos doesn’t really get into the exercises as much as he advertised. So I’ve decided to do my own little mini exercises to try and push myself through this course, as well as notes. I’m starting with Module 3

Module #3 – The tricky bits

My Notes

Using global variables is not a good idea
Any variable declared inside a function is only available inside that function. 
//This works
function go() {
  const hair = 'blonde';
  console.log(hair);
}
//This does not work
function go(){
  const hair = 'blonde';
}
go()

const and let are not available outside of a code block. 
//Does not work
if (1 === 1) {
  const = true;
}
console.log(cool)
Way around is to declare the variable above the code block, and give the variable a value inside the block
//Does work
let cool;
if (1 === 1) {
  cool = true;
}
console.log(cool);
//showing the different scopes 
//block scoping
//var variables are not block scoped
function isCool(name){ //this is called a functionScope
let cool;
if (1 === 1) {
  cool = true;
}
console.log(cool);
return cool;
}

Share this post
Facebook
Twitter
LinkedIn

Author: Deborah Butler

I’m passionate about diversity in WordPress & Tech, and have been a diversity community leader for the Codeable Women Experts and the LGBTQI+ Experts on the platform for 2yrs.

Need Help With Your Website?

I'd love to chat more about your vision!