Skip to content

Instantly share code, notes, and snippets.

https://repl.it/@jeffreymahmoudi/Wiseperson-generator-drill
https://repl.it/@jeffreymahmoudi/shouter-drill
https://repl.it/@jeffreymahmoudi/text-normalizer-drill
https://repl.it/@jeffreymahmoudi/area-of-a-rectangle-drill
https://repl.it/@jeffreymahmoudi/temperature-conversion-drill
https://repl.it/@jeffreymahmoudi/Is-divisible-drill
https://repl.it/@jeffreymahmoudi/Traffic-lights-drill
https://repl.it/@jeffreymahmoudi/Error-alert-drill
https://repl.it/@jeffreymahmoudi/Creating-arrays-drill
https://repl.it/@jeffreymahmoudi/Adding-array-items-drills
https://repl.it/@jeffreymahmoudi/Accessing-array-items-drill
https://repl.it/@jeffreymahmoudi/Array-length-and-access-drill
https://repl.it/@jeffreymahmoudi/Array-copying-I-drill
https://repl.it/@jeffreymahmoudi/Array-copying-II-drill
https://repl.it/@jeffreymahmoudi/Squares-with-map-drill
https://repl.it/@jeffreymahmoudi/Sort-drill
https://repl.it/@jeffreymahmoudi/Filter-drill
https://repl.it/@jeffreymahmoudi/Find-drill
https://repl.it/@jeffreymahmoudi/min-and-max-without-sort-drill
https://repl.it/@jeffreymahmoudi/average-drill
https://repl.it/@jeffreymahmoudi/fizzbuzz-drill-js
What is scope?
Scope defines how variables can or cannot be accessed in different places in code. Global scope allows all code to use the variable while block scope is restriced to the block it is defined in.
Why are global variables avoided?
Global variables can cause side effects like causing a function to become indeterminate.
Explain JavaScript's strict mode.
Strict mode forces all functions to use let or const when defining a variable.
What are side effects, and what is a pure function?
https://repl.it/@jeffreymahmoudi/Object-creator-drill
https://repl.it/@jeffreymahmoudi/Object-updater-drill
https://repl.it/@jeffreymahmoudi/Self-reference-drill
https://repl.it/@jeffreymahmoudi/Deleting-keys-drill
function getTokens(rawString) {
// NB: `.filter(Boolean)` removes any falsy items from an array
return rawString.toLowerCase().split(/[ ,!.";:-]+/).filter(Boolean).sort();
}
function mostFrequentWord(text) {
// Turn the text into an array of tokens
let words = getTokens(text);
// Create an empty object to hold data about each word.
let wordFrequencies = {};
// ================================================================================
// You will be writing a series of functions beneath each block of comments below.
// Tackle each function one at a time. You may move on to a new exercise and return
// later. Run the code and the console to the right will tell you if your function
// is successfully passing the tests.
// ================================================================================
/*
Define a function named `kmToMiles` that receives one parameter: