Skip to content

Instantly share code, notes, and snippets.


Keybase proof

I hereby claim:

To claim this, I am signing this object:

View mongo basic drills
// GET all
//limit and sort
db.restaurants.find().sort({name: 1)).limit(10);
//GET by _id
View Advanced Object Drills
View Object Basic Drills,js,output,console,console,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") {
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!