Skip to content

Instantly share code, notes, and snippets.

View wilm42's full-sized avatar

Violet wilm42

  • Everywhere, man.
View GitHub Profile
@wilm42
wilm42 / js string drills
Created April 17, 2017 14:24
js string drills
wiseperson drill - https://jsbin.com/sulize/edit?js,console
normalizer drill - https://jsbin.com/culojep/edit?js,console
shouter drill - https://jsbin.com/mazuno/edit?js,console
@wilm42
wilm42 / js number drills
Created April 17, 2017 14:45
js number drills
computeArea - https://jsbin.com/vemehiv/edit?js,console
Temperature Conversion - https://jsbin.com/hufaje/edit?js,console
Modulo drill - https://jsbin.com/yaxehos/edit?js,console
@wilm42
wilm42 / js logic drills
Created April 17, 2017 18:04
js logic drills
Traffic lights - https://jsbin.com/luyefom/edit?js,output
Error Handling - https://jsbin.com/kivenic/1/edit?js,console,output
@wilm42
wilm42 / js array drills
Created April 18, 2017 14:58
js array drills
make an array - https://jsbin.com/qatizuj/edit?js,console,output
using .push - https://jsbin.com/roziri/edit?js,console,output
accesing items - https://jsbin.com/nuwoha/edit?js,console,output
using .length - https://jsbin.com/hizoke/edit?js,console,output
copy I - https://jsbin.com/bifase/edit?js,console,output
copy II - https://jsbin.com/sujaci/edit?js,console,output
using .map - https://jsbin.com/hoticil/edit?js,console,output
using .sort - https://jsbin.com/noliqi/edit?js,console,output
using .filter - https://jsbin.com/lacaxez/edit?js,console,output
using .find - https://jsbin.com/ruxefi/edit?js,console,output
max/min- https://jsbin.com/yapelir/edit?js,console,output
average- https://jsbin.com/fodevim/edit?js,console,output
fizzbuzz- https://jsbin.com/kuzupe/edit?js,console,output
@wilm42
wilm42 / scope
Created April 18, 2017 18:36
answering questions related to scope and global variables
Q1: What is scope?
'Scope' refers to the places that a variable can be called on in javascript. A variable with 'local scope' is one that
is defined within a specific function, and can only be used within that function. If it is used elsewhere without being
redefined, you'll get an uncaught ref error. A variable with 'global scope' is one that is defined outside of a function.
variables with global scope can be called on anywhere in your code, even between files.
Q2: Why are global variables avoided?
Global variables are to be avoided because they cause a lot of bugs. The reason they cause a lot of bugs is because you can
accidentally mutate them in a function, and then when you call on them again later, the mutated data held by the variable
is not what you were expecting. By keeping your variables local, you're creating a variable and then directly working with it,
https://jsbin.com/diguso/edit?html,js,output
https://jsbin.com/wumoxa/edit?js,console,output
https://jsbin.com/jumifaw/edit?js,console,output
https://jsbin.com/xacuwod/edit?js,output
https://jsbin.com/jamicur/edit?js,console,output
https://jsbin.com/wimeto/edit?js,console,output
https://jsbin.com/recevi/edit?js,console,output
https://jsbin.com/qiwowi/edit?js,console,output
https://jsbin.com/waxutos/edit?js,console,output
@wilm42
wilm42 / Most Frequent Word
Last active April 19, 2017 21:02
A description of how the Most Frequent Word code works
This code starts out by declaring a function they call getTokens, which just parses the raw text that is input and
breaks it down into a usable form: all lowercase, as an array without any punctuation, without any
falsy items (no null, undefined, etc), and sorted alphabetically.
Then it declares the main function, mostFrequentWord. This function is where you'll input the chunk of text you want to analyze
first, it sets a variable called words that runs the aforementioned getTokens function - what this does is sets our words
variable to be a nice clean list (array) of words in alphabetical order. Then it sets up an empty object called wordFrequencies, where
we're going to hold the wordcount data as we go along.
Next, it loops through each item on the words list. It checks to see if we already have an entry (key) for that word in our
@wilm42
wilm42 / gist:dd7d97cc24162266888bc5ca5260835d
Created May 22, 2017 19:44
KyleS / William / Node & Express Drills day 1
https://glitch.com/edit/#!/precious-robin?path=server.js:21:0
https://glitch.com/edit/#!/mighty-antler?path=server.js:21:0
https://glitch.com/edit/#!/nimble-factory?path=server.js:29:48