Skip to content

Instantly share code, notes, and snippets.

View mzibari's full-sized avatar


View GitHub Profile
mzibari / gist:c9515a761bdd028857873bf2ec467812
Created January 18, 2020 02:40
Module 5 Checkpoint 6 Drills
mzibari / gist:78ab684760d387e9a9aac26b21c51784
Created January 18, 2020 03:25
Module 5 Checkpoint 7 Drills
mzibari / gist:adf406ee4c4084dcf5994182b5ddbaeb
Created January 18, 2020 22:39
Module 5 Checkpoint 7 Drills
mzibari / gist:4ccd92b96d3a35f78e3f6a3879ab49ea
Created January 20, 2020 02:36
Module 5 Checkpoint 9 Drills
mzibari / gist:0a5947a7da2a677ea991652e33c2fdd8
Created January 20, 2020 03:23
Module 5 Checkpoint 10 Drills
mzibari / Module 5 Checkpoint 11 Assignment
Last active January 20, 2020 04:10
Answers to assignment questions
Scope is the accessibility to a vairable in different parts of the program. Global variables can be accessed anywhere in the program, while block variables can only be accessed within that particular block that they're declared in.
Global variables should be avoided, except in specific cases, because they will cause unintended side effects that will cause bugs, especially in larger programs, that will be hard to track down.
Strict mode will trigger an uncaught reference error any time a variable is declared without 'let' or 'const' keywords, it's used to stop the accidental creation of indeteminate code.
Side effects are the accidental alteration of a global variable's value that will effect the outputs of a different function or a block of code. Pure function is a function that when provided with the same inputs will always have the same outputs.
We start with the function "getTokens", which takes a single argument "rawString". it will change all letters to lower case letters, since java script is case sensative, when we compare the amount of times a particular word has occured, we don't want the word "This" be considered a diffirent word from "this". Then the function will remove all symboles and return all the words as an array of strings. In our code, the returned array will be stornd in "words" array.
We then create an object "wordFrequencies" that we will later use to store all unique words as keys, and the frequency of thoses keys as thier values.
After that, we itirate through the "words" array using a for loop, counting each occurance of words and storing that information in our "wordFrequencies" object.
In the last part, we use a for( loop to determine which key has the largest frequency, and based on that result, we return the key of the most frequent word.
There's a more detailed line by line description of the code in the link bel
mzibari / CSS file
Last active February 13, 2020 00:23
Quiz App
text-align: center;
font-family: 'Anton', sans-serif;
font-size: 30px;
/*background-image: url("");*/
background-repeat: repeat;