Skip to content

Instantly share code, notes, and snippets.

ryanlovesnode ryanbsherrill

Block or report user

Report or block ryanbsherrill

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ryanbsherrill
ryanbsherrill / cat carousel
Created Mar 11, 2017
Event Listener Drills
View cat carousel
@ryanbsherrill
ryanbsherrill / wordProblem.js
Created Feb 27, 2017
analyze a most frequent word problem
View wordProblem.js
/* GET TOKENS: this function takes a 'raw string' and 'gets'/organizes every
character and word in 'alphabetical order' inside of an array. each of the words
and chars which were once part of a single string have now been given their own
index positions */
function getTokens(rawString) {
// NB: `.filter(Boolean)` removes any falsy items from an array
return rawString.toLowerCase().split(/[ ,!.";:-]+/).filter(Boolean).sort();
}
// mostFrequentWord is a function that takes a string of text as its argument
View enroll in summer school
.map:
https://jsbin.com/yowisob/edit?js
for loop:
https://jsbin.com/yowisob/edit?js
View deleting keys
https://jsbin.com/wiruzez/edit?js
@ryanbsherrill
ryanbsherrill / Challenge: In Your Own Words
Created Feb 24, 2017
Scope and the Problem with Globals
View Challenge: In Your Own Words
Scope refers to the regions of your code in which your variables can be accessed. If a variable is within
the global scope, it means that it can be accessed from any other place in your program. If a variable is
local to a function, that means that it can only be accessed by the code inside the block of that function.
Global variables are avoided because they can cause all kind of unintended side effects. These side
effects can cause parts of your program to produce different results when given the exact same inputs,
which is obviously not a good thing.
Strict mode forces the user to be more careful with their syntax by throwing errors where the code
would normally just run. Things such as: if a function parameter name were not unique within whole of the
@ryanbsherrill
ryanbsherrill / FizzBuzz
Created Feb 24, 2017
arrays and loops drills
View FizzBuzz
https://jsbin.com/bumocas/edit?js
View accessing array items
https://jsbin.com/bicegoh/edit?js
View error alert link
View areaOfRectangle.js
// Area of a Rectangle
function computeArea(width, height) {
return width * height;
}
function testComputeArea() {
var width = 3;
var height = 4;
var expected = 12;
You can’t perform that action at this time.