Skip to content

Instantly share code, notes, and snippets.

View 821jieun's full-sized avatar

jieun 821jieun

  • nyc
View GitHub Profile
821jieun / gist:fc4d0229485cae77b83ff8b7ae385ce4
Created February 14, 2018 15:38
Links to string drills
821jieun / gist:bd4c6304491debb32c34147147479e28
Created February 14, 2018 17:07
Arrays and Loops Drills
821jieun / gist:7f18fb0c20853bd023629bcf7b12dd89
Created February 14, 2018 18:12
Challenge: in your own words
What is scope? Your explanation should include the idea of global vs. local scope.
Scope is the area in which a variable is available.
Local scope is when the variable is defined and used within a specific function. Local scope is re-created
each time the function is called.
Global scope is when the variable is defined outside of a function.
The interpreter follows a scope chain to check the availability of a variable. It will first check local scope;
then it will check parent scope; then it will check the global scope.
Why are global variables avoided?
Use of global variables can make a function indeterminate. This means that a when a function is given the same input
821jieun / gist:611089050e21047f3a552cbe458918f1
Created February 14, 2018 20:23
most frequent word analyzer challenge
function getTokens(rawString) {
// NB: `.filter(Boolean)` removes any falsy items from an array
return rawString.toLowerCase().split(/[ ,!.";:-]+/).filter(Boolean).sort();
//all capitalized letters are turned into lower case letters in the raw string.
//that all lower case string is then being split where punctuation marks are found.
//falsy items are removed.
//the string is then sorted alphabetically and is the return value of the getTokens function call.