Skip to content

Instantly share code, notes, and snippets.

View psychicbologna's full-sized avatar

Alex Fukui psychicbologna

View GitHub Profile
https://repl.it/@afukui/Wiseperson-generator-drill
https://repl.it/@afukui/shouter-drill
https://repl.it/@afukui/text-normalizer-drill
@psychicbologna
psychicbologna / gist:addec7642de928ee7d9cad408d4f25c4
Last active July 17, 2019 09:44
JS Fundamentals - 9 (Array Basics)
https://repl.it/@afukui/Creating-arrays-drill
https://repl.it/@afukui/Adding-array-items-drills
https://repl.it/@afukui/Accessing-array-items-drill
https://repl.it/@afukui/Array-length-and-access-drill
@psychicbologna
psychicbologna / gist:540fb93f11dc533310c76f19a11ffd0c
Last active July 17, 2019 10:32
JS Fundamentals - 9 (Array Methods)
https://repl.it/@afukui/Array-copying-I-drill
https://repl.it/@afukui/Array-copying-II-drill
https://repl.it/@afukui/Squares-with-map-drill
https://repl.it/@afukui/Sort-drill
https://repl.it/@afukui/Filter-drill
https://repl.it/@afukui/Find-drill
https://repl.it/@afukui/min-and-max-without-sort-drill
https://repl.it/@afukui/average-drill
https://repl.it/@afukui/fizzbuzz-drill-js
-What is scope? Your explanation should include the idea of global vs. block scope.
Scope allows Javascript to define how a variable is or isn't accessed and mutated by code in functions based on how specifically it is
designated in the block chain. It searches for the value for a variable name from within the current scope outward to parent scopes
until it reaches the global level. This prevents variables with the same name but different values set within functions from colliding
with each other and breaking the code by giving block scope precendence over global scope.
When setting variables using let and const, there are two kinds of variable scopes in Javascript: global and block. A global variable is
declared outside of a function. It is available everywhere in the code and even between files if they are called in proper order. A
block variable is declared within a function, and is only accessable locally to the function in which it is declared.
https://repl.it/@afukui/Object-creator-drill
https://repl.it/@afukui/Object-updater-drill
https://repl.it/@afukui/Self-reference-drill
https://repl.it/@afukui/Deleting-keys-drill
A function (getTokens) is called with rawString as the argument representing the text. This function creates a sorted array of individual words based on a block of text passed through it which we can then sort more easily. The function starts with a returned chain of methods, first converting the string to lower case characters with .toLowerCase() to make sure capitalized words aren't accidentally segregated from the same words in lower case. It uses .split() with a regex, or regular expression, telling it to split the string into an array of smaller strings wherever there are spaces or punctuation. Next, .filter(Boolean) removes falsy items from the array, to make sure no empty strings make it through. Finally, it's sorted by alphabetical order using a basic .sort() and returned.
This function is called in the following function, mostFrequentWord(text), where the bulk of the work is done. The text is passed as an argument. An array variable is declared using getTokens, which will create a block variable arr
URL:
https://thinkful-ei-gecko.github.io/Alexander-Preet-QuizApp/
Alexander Fukui and Preet Singh
Alex Fukui
Pseudocode for three functions in Shopping Items List
function render(){
//Re-renders list after changed are put through.
}
function handleNewItemSubmit() {
// this function will be responsible for when users add a new shopping list item
$('.js-shopping-list-form').submit(function (event) {
Alex Fukui individual
*********** Link to Replit
https://repl.it/@afukui/jquery-shopping-list-walkthrough-v2-14
*********** NOTES
- The provided solution implemented the more graceful code:
const itemIndex = STORE.findIndex(item => item.id === itemId);