Skip to content

Instantly share code, notes, and snippets.

View sharihobbs's full-sized avatar

Shari Hobbs sharihobbs

View GitHub Profile
Area of a rectangle https://repl.it/G9Do/680
Temp conversion https://repl.it/G9EI/771
Is divisible https://repl.it/Mym1/0
Traffic light drill https://repl.it/Ggbk/1289
Error alert solution https://repl.it/GgdO/8
Creating arrays https://repl.it/G9GB/1039
Adding array items https://repl.it/G9GI/1068
Accessing array items https://repl.it/G9GO/793
Array length and access https://repl.it/G9GS/933
Array copying I https://repl.it/G9GV/latest
Array copying II https://repl.it/G9G7/latest
Squares with map https://repl.it/G9HI/latest
Sort https://repl.it/G9H5/latest
Filter https://repl.it/G9Hd/latest
Find https://repl.it/G9Hl/latest
@sharihobbs
sharihobbs / gist:44adde4f85444c325b36a492828d6045
Created October 23, 2017 17:24
JS Arrays & Loops Drills
Min/max https://repl.it/G9KJ/latest
Compute the average https://repl.it/G9KO/1103
fizz buzz https://repl.it/G9KW/1649
What is scope? Your explanation should include the idea of global vs. local scope. // Scope ultimately determines how accessible the variables are within your code. Variables that are declared in the global scope are available for use throughout the file. Variables that are declared in the local scope are available for use only within their function and are not even visible outside of that function. It is important to not declare variables globally unless you have a very good reason to do so as this can create several issues within your code. Working within the local scope makes your code more dependable and agile moving forward.
Why are global variables avoided? // Declaring variables globally allows them to be accessed anywhere in the file which can result in difficult-to-troubleshoot bugs and issues with concurrency. It can also make code difficult to read and/or understand. By using local variables, you maintain a more limited scope and can work with a function (or other section of code) independently. T
Object creator https://repl.it/G9Lb/latest
Object updater https://repl.it/G9Lf/latest
Self reference https://repl.it/G9Lj/latest
Deleting keys https://repl.it/G9Lo/latest
Make student report https://repl.it/G9NG/latest
Enroll in summer school https://repl.it/G9N6/latest
Find by id https://repl.it/G9OF/latest
Validate object keys https://repl.it/G9OV/latest
@sharihobbs
sharihobbs / gist:bcf37ba3135c01ed48563b8f8bec8a72
Created October 25, 2017 19:40
Most frequent word - analysis
Line 1 declares function getTokens which passes in rawString as an argument.
Line 2 changes rawString to all lower case letters and removes all punctuation (with a split). It also filters out falsy items from the array and sorts alphabetically.
Line 6 declares function mostFrequentWord which passes in text as an argument. (?? what is "text" here?)
Line 7 declares variable words and assigns getTokens(text) as the value <~ why?.
Line 8 declares variable wordFrequencies and creates an empty object (denoted by {} and not [] which would be an array).
Line 9 begins a for loop with an if/else statment in it. The for conditions: i starts at the first position in the object(??) and for as long as i is less than or equal to the length of words (the variable declared on line 7), increment by 1 through the object(again??).
Lines 10-15 begin the if/else statment in the for loop... stating that if the word currently being evaluated in the loop is "in" the wordFrequencies object, continue iterating through else consider t