Skip to content

Instantly share code, notes, and snippets.

View leovolving's full-sized avatar

Leo Yockey leovolving

View GitHub Profile
https://jsbin.com/fopehi/1/edit?js,console
https://jsbin.com/damizuc/1/edit?js,console
https://jsbin.com/tutunid/1/edit?js,console
https://jsbin.com/jefohir/1/edit?js,console
https://jsbin.com/tafuha/1/edit?js,console
https://jsbin.com/gaviwun/1/edit?js,console
https://jsbin.com/metovev/1/edit?js,output
https://jsbin.com/nehami/edit?js,console,output
https://jsbin.com/diyuyep/edit?js,console
https://jsbin.com/wavujow/edit?js,console
https://jsbin.com/ceyisan/edit?js,console
https://jsbin.com/mapubos/edit?js,console
https://jsbin.com/gerofuc/edit?js,console
https://jsbin.com/qonanot/edit?js,console
https://jsbin.com/neqotiw/edit?js,console
https://jsbin.com/vuyasaj/edit?js,console
https://jsbin.com/dajuta/edit?js,console
https://jsbin.com/teniwa/edit?js,console
https://jsbin.com/golutog/edit?js,console
https://jsbin.com/sebihu/edit?js,console
https://jsbin.com/duzeve/edit?js,console
*What is scope? Your explanation should include the idea of global vs. local scope.
Scope defines the area in which a variable either can or cannot be reached. For example, if I were to declare a variable
outside of a function, it would be considered a global variable and can be accessed/manipulated at any point thereafter
within my JS file or any JS files that follow it in an HTML file. If I were to declare a variable within a function, it
would be considered a local scope and can only be accessed or manipulated within that variable.
*Why are global variables avoided?
Global variables are generally avoided because they can have unwanted outcomes in the code. Because a global function can
be manipulated within any function within my code, the value of that variable can be unpredictable and even unreliable. The
variable would become indeterminant, meaning I would not be assured that, within a paricular function, my variable would
https://jsbin.com/tinohe/edit?js,console
https://jsbin.com/tuletiz/edit?js,console
https://jsbin.com/tiwiyav/edit?js,console
https://jsbin.com/haxaxox/edit?js,console
https://jsbin.com/yalutey/edit?js,console
https://jsbin.com/migawud/edit?js,console
https://jsbin.com/qamedod/edit?js,console
https://jsbin.com/zavixuc/edit?js,console
Lines 1-4: A function that takes a string and removes the special characters and upper case letters so that may be attached to a word.
Line 6: Begins the function
Line 7: Runs the text inputted into the function into the getTokens function so that everything is lowercase and the special characters are removed. The result will be a new variable which will be used for the mostFrequentWord function
Line 8: Creates an empty object in which all of the words will be placed
Lines 9-16: A function in which each word in the variable "words" will be passed through. If that word is not already a key in the object wordFrequencies, the value will be 1. If the word is already in wordFrequencies, the value will be +=1.
Line 17: a new variable in which we will store the word with the most frequent iterations from the object wordFrequencies
Line 18: A new variable which keeps track of the current "maximum word" based on the object key
Cat Carousel - https://jsbin.com/vanayam/edit?html,js,console,output
Fizz Buzz - https://jsbin.com/hapusoc/3/edit?html,js,output
Lightbulb - https://jsbin.com/wolubo/edit?html,js,output