Skip to content

Instantly share code, notes, and snippets.

//For the 3 remaining user stories (add items, check/uncheck items, and delete items),
//plan out each function in pseudocode (plain language).
function handleNewItemSubmit() {
// this function will be responsible for when users add a new shopping list item
// on user pressing 'add to cart', capture value in text field
// create an object {id: cuid(), name: "value from text field", checked: false}
//pass object to generateItemElement(item) and storing the result
//add it to the store
https://repl.it/@kp8/Cat-carousel-jQuery
https://repl.it/@kp8/return-of-fizz-buzz
function getTokens(rawString) {
// NB: `.filter(Boolean)` removes any falsy items from an array
return rawString.toLowerCase().split(/[ ,!.";:-]+/).filter(Boolean).sort();
}
function mostFrequentWord(text) {//this is our entry point. It accepts a raw text parameter
/*the text parameter is scrubbed using the getTokens function.
The getTokens function converts the entered text all to lowercase if it isnt already, using toLowerCase(). Splits the text into an array, splitting on any non-word character such as a comma or full stop, using split() along with regex to match single or multiple instances of said characters. The filter() method is then employed to assist in removing any empty array values that split may have created. Things like an empty string, or undefined array element. Not 100% sure what split would have missed. Maybe test to find out. Finally sort is used to place all the elements in alphabetical order. sort by default doesn't need an argument as it compares it's first term to its se
https://repl.it/@kp8/Make-student-reports-drill
https://repl.it/@kp8/Enroll-in-summer-school-drill
https://repl.it/@kp8/find-by-id-drill
https://repl.it/@kp8/validate-object-keys-drill
https://repl.it/@kp8/Object-creator-drill
https://repl.it/@kp8/Object-updater-drill
https://repl.it/@kp8/Self-reference-drill
https://repl.it/@kp8/Deleting-keys-drill
Scope is a way of understanding the locality of variables in a Javascript environment. A function is an enclosed program, and thus has it's own private (to the outside environment) scope called it's local scope. A variable declared within a function exists only within that function. This has the benefit of limiting any side-effects to the outside environment as the function only acts upon variables within itself. Of course, functions within said function (nested functions) do have access to the variables "above" them. Global variables on the other hand are variables that exist outside the body of any function in particular. It's a variable that all functions will see as "above" themselves, and thus have access to it. The problem with this, is that during execution, if many functions have access to a variable, it becomes difficult to track where errors might arise in a variable's value being changed, and that change may be unwanted. As this global variable exists outside of these functions, mutating it is call
https://repl.it/@kp8/min-and-max-without-sort-drill
https://repl.it/@kp8/average-drill
https://repl.it/@kp8/fizzbuzz-drill-js
https://repl.it/@kp8/Array-copying-I-drill
https://repl.it/@kp8/Array-copying-II-drill
https://repl.it/@kp8/Squares-with-map-drill
https://repl.it/@kp8/Sort-drill
https://repl.it/@kp8/Filter-drill
https://repl.it/@kp8/Find-drill
https://repl.it/@kp8/Creating-arrays-drill
https://repl.it/@kp8/Adding-array-items-drills
https://repl.it/@kp8/Accessing-array-items-drill
https://repl.it/@kp8/Array-length-and-access-drill
https://repl.it/@kp8/Traffic-lights-drill
https://repl.it/@kp8/Error-alert-drill