Skip to content

Instantly share code, notes, and snippets.

View tdesire's full-sized avatar

Tarik Desire tdesire

  • Miami, FL
View GitHub Profile
https://repl.it/@tdesire/Wiseperson-generator-drill
https://repl.it/@tdesire/shouter-drill
https://repl.it/@tdesire/text-normalizer-drill
https://repl.it/@tdesire/area-of-a-rectangle-drill
https://repl.it/@tdesire/temperature-conversion-drill
https://repl.it/@tdesire/Is-divisible-drill
https://repl.it/@tdesire/Traffic-lights-drill
https://repl.it/@tdesire/Error-alert-drill
https://repl.it/@tdesire/Creating-arrays-drill
https://repl.it/@tdesire/Adding-array-items-drills
https://repl.it/@tdesire/Accessing-array-items-drill
https://repl.it/@tdesire/Array-length-and-access-drill
https://repl.it/@tdesire/Array-copying-I-drill
https://repl.it/@tdesire/Array-copying-II-drill
https://repl.it/@tdesire/Squares-with-map-drill
https://repl.it/@tdesire/Sort-drill
https://repl.it/@tdesire/Filter-drill
https://repl.it/@tdesire/Find-drill
https://repl.it/@tdesire/min-and-max-without-sort-drill
https://repl.it/@tdesire/average-drill
https://repl.it/@tdesire/fizzbuzz-drill-js
Variable scope defines where a variable can be accessed and modified within a body of code.
Scope typically falls into two categories: global scope and block scope.
A variable with global scope is one that has been declared outside the body (block) of a particular function. It is considered global
because it can be accessed and modified anywhere within the code, including within the body of a function.
In contrast, a variable with block scope is one that has been declared within a function's instruction block (delineated by {} brackets),
and can thus only be accessed and/or modified within that function's body.
It is considered programming best-practice to avoid the use of global variables because of their universal mutability. By that I mean,
it is possible for programmers to modify the value of a global variable from within a function's (local) instruction block.
This phenomenon, known as a side-effect, can have dire consequences when executed unintentionally, given that it can lead to
https://repl.it/@tdesire/Object-creator-drill
https://repl.it/@tdesire/Object-updater-drill
https://repl.it/@tdesire/Self-reference-drill
https://repl.it/@tdesire/Deleting-keys-drill
https://repl.it/@tdesire/Make-student-reports-drill
https://repl.it/@tdesire/Enroll-in-summer-school-drill
https://repl.it/@tdesire/find-by-id-drill
https://repl.it/@tdesire/validate-object-keys-drill
\\(num) -- refers to the line number of the original code.\\
(6) Accepts text (a body of text) as an argument.
(7) Passes text to the getTokens function as an argument, which removes all punctuation marks (falsy characters)
from text and adds the filtered text to a new array.
This new array is then sorted (alphabetically by default) and set to the variable words.
(8) Sets variable wordFrequencies to an empty object. Each key in this object will correspond to a specific word in words, and each
key value represents the number of times that word has occured in the text.
(9-15) Iterates through the words array; if the word in words is not a key in wordFrequencies, then it is a new word, and is added
to wordFrequencies with a key value set to 1 (since it has occured once). If word in words is in wordFrequencies, then add 1