Skip to content

Instantly share code, notes, and snippets.

View codeangler's full-sized avatar

Casey Burnett codeangler

View GitHub Profile
function showName () {
console.log("Casey Burnett")
}
showName()
var favouriteColor = "green";
function showColor() {
console.log(favouriteColor);
}
showColor();
favouriteColor = "green";
function showColor() {
var secondFavouriteColor = "red";
console.log(favouriteColor);
console.log(secondFavouriteColor);
}
showColor();
console.log(favouriteColor);
// doesn't display as local scope
console.log(secondFavouriteColor);
var car = "Honda Civic";
showCar();
var showCar = function(){
console.log(car);
};
// Because of hoisting the function expression is hoisted prior to the assignment of the function expression. Thus the call of the showCar(); breaks .
var car = "Honda Civic";
showCar();
// By making it a function declaration scope & hoisting are not an issue
function showCar(){
console.log(car);
}
var food = "pizza";
function getFood(){
console.log(food); //what does this line alert?
// Assigning var food is hoisted w/n function w/o assignment and first console.log returns undefined. Then var food is assigned saugages and returns "sausages"
var food = "sausages";
console.log(food); // what does this line alert?
}
@codeangler
codeangler / settings.json
Created September 12, 2016 21:22 — forked from wesbos/settings.json
Wes Bos' Sublime Text Settings
{
"added_words":
[
"Mockup",
"plugins",
"coffeescript",
"sourcemaps",
"html",
"plugin",
"init",
@codeangler
codeangler / prefix_postfix_incrementors_filter.js
Last active September 30, 2016 15:59
prefix incrementor vs postfix incrementor is critical for this to work ++prev != prev++
// 7. Write a JavaScript function that accepts a string as a parameter and counts the number of vowels within the string. Go to the editor
// Note : As the letter 'y' can be regarded as both a vowel and a consonant, we do not count 'y' as vowel here.
// Example string : 'The quick brown fox'
// Expected Output : 5
((str) => console.log(
str.split('')
.reduce(
(prev, current) => {
if("aeiouAEIOU".split('').indexOf(current) != -1){
return ++prev;