Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

To claim this, I am signing this object:

View mongo basic drills
// GET all
db.restaurants.find()
//limit and sort
db.restaurants.find().sort({name: 1)).limit(10);
//GET by _id
View Advanced Object Drills
recipe: https://jsbin.com/xeyege/edit?html,js,output
dataMerge: https://jsbin.com/visobor/edit?js,console,output
mostFrequentWord: https://jsbin.com/fopoyu/edit?js,console
View Object Basic Drills
https://jsbin.com/yoxumuj/edit?html,js,output
https://jsbin.com/heqifik/1/edit?js,console
https://jsbin.com/sacoden/edit?js,console
https://jsbin.com/jixuped/edit?js,console
View Scope Global vs Local
1. What is scope? Your explanation should include the idea of global vs. local scope.
-JavaScript has two scopes, global and local. When a variable is declared outside of a function it has a global scope and is available from anywhere in the code. A local scope is a variable that is declared inside of a function and can only be used for that function.
2. Why are global variables avoided?
- Global Variables can create unintended side effects in your code. This can potentially make your code very difficult to debug.
3. Explain JavaScript's strict mode
- Strict mode will trigger an error anytime the VAR keyword is not used before declaring a variable. This prevents global variables from occuring.
View [Arrays] and (Loops) Drills
////////Max and Min//////////
function max(numbers) {
var currentMax = numbers[0];
for (var i = 0; i <= numbers.length; i++) {
if (numbers[i] > currentMax) {
currentMax = numbers[i];
}
} return currentMax;
}
View Logic Drills
///Traffic Lights
function doTrafficLights() {
var activeLight = getActiveLight();
//your code will replace this call
//to `console.log()'
if (activeLight === "red") {
console.log(turnRed());
}
else if (activeLight === "yellow") {
View Number Drills
// Square Area
function computeArea(width, height) {
return width * height;
}
/* From here down, you are not expected to
understand.... for now :)
View String Drills
function wisePerson(wiseType, whatToSay) {
return 'A wise ' + wiseType + ' once said: "' + whatToSay + '".'
}
/* From here down, you are not expected to
understand.... for now :)
Nothing to see here!