Skip to content

Instantly share code, notes, and snippets.

View RyanCahela's full-sized avatar

Ryan Cahela RyanCahela

View GitHub Profile
@RyanCahela
RyanCahela / StringMethodDrills
Created December 23, 2018 22:31
String drills for Thinkful prep course
//Wise Person Drill
https://repl.it/@Stompy32/Wiseperson-generator-drill
//Shouter Drill
https://repl.it/@Stompy32/shouter-drill
//String Normalizer
https://repl.it/@Stompy32/text-normalizer-drill
@RyanCahela
RyanCahela / Number Drills
Created December 24, 2018 00:31
Number drills for Thinkful prep course
//Area of a rectangle
https://repl.it/@Stompy32/area-of-a-rectangle-drill
//Temperature conversion
https://repl.it/@Stompy32/temperature-conversion-drill
//Is divisable drill
https://repl.it/@Stompy32/Is-divisible-drill
//Traffic Light
https://repl.it/@Stompy32/Traffic-lights-drill
//Error Alert
https://repl.it/@Stompy32/Error-alert-drill
//Creating Arrays
https://repl.it/@Stompy32/Creating-arrays-drill
//Adding array items
https://repl.it/@Stompy32/Adding-array-items-drills
//Accessing array items
https://repl.it/@Stompy32/Accessing-array-items-drill
//Array length and access
//Array Copying I
https://repl.it/@Stompy32/Array-copying-I-drill
//Array Copying II
https://repl.it/@Stompy32/Array-copying-II-drill
//Squares with map
https://repl.it/@Stompy32/Squares-with-map-drill
//Sort
//Max/min drill
https://repl.it/@Stompy32/min-and-max-without-sort-drill
//Compute the average
https://repl.it/@Stompy32/average-drill
//fizz buzz
https://repl.it/@Stompy32/fizzbuzz-drill-js
In javascript scope is the idea that variables are only accessible within a certain context.
Where the variable is declared is considered to be its lexical scope. Variables created in the highest lexical scope
otherwise known as the 'global scope' are gernerally considered a bad idea. Globals can potentially intoduce unintended
variable assignment that make your program hard to reason about. If you are not careful declaring global variables can cause your functions to produce side effects.
Function side effects are when a function changes something outside of its scope. Sometimes side effects are intentional such as saving data to a data base.
When function side effects are unintentional is when bugs can arise. Its considered good practice to make your functions 'pure' (without side effects) unless you have a specific reason.
We can utilize 'use strict'; in javascript as a safe guard agains creating global vaiables. When in strict mode the javascript engine will throw an error whenever a global variable is d
//Object Creator
https://repl.it/@Stompy32/RealisticGrimFactor
//Object Updater
https://repl.it/@Stompy32/Object-updater-drill
//Self-Reference
https://repl.it/@Stompy32/Self-reference-drill
//Deleting Keys
//Make student reports
https://repl.it/@Stompy32/Make-student-reports-drill
//Enroll in summer school
https://repl.it/@Stompy32/Enroll-in-summer-school-drill
//Find by id
https://repl.it/@Stompy32/find-by-id-drill
//Validate object keys
function getTokens(rawString) {
// NB: `.filter(Boolean)` removes any falsy items from an array
//returns an array of words that are lowercase and sorted alphabetically
return rawString.toLowerCase().split(/[ ,!.";:-]+/).filter(Boolean).sort();
}
function mostFrequentWord(text) {
let words = getTokens(text);
//creates an empty object