This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GET ALL | |
# Command that retrieves all restaurants | |
$ db.restaurants.find(); | |
# LIMIT AND SORT | |
# Find the command that makes the first 10 restaurants appear alphabetically by 'name' | |
$ db.restaurants. | |
find(). | |
sort({name:1}). | |
limit(10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const queryString = require('query-string'); | |
const app = express(); | |
const USERS = [ | |
{ | |
id: 1, | |
firstName: 'Joe', | |
lastName: 'Schmoe', | |
userName: '[email protected]', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example 1: ECHO ENDPOINT | |
'use strict' | |
const express = require('express'); | |
const app = express(); | |
app.get('/echo/:what', (req, res) => { | |
res.json({ | |
host: req.hostname, | |
path: req.path, | |
query: req.query, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// **** GLOBAL STATE OBJECT **** | |
var state = { | |
items: [], | |
}; | |
// **** HTML TO RENDER **** | |
var listItemTemplate = | |
'<li>' + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Thinkful | Text analyzer example solution</title> | |
<meta charset="utf-8" /> | |
<meta | |
name="description" | |
content="Exemplary solution for the text analyzer project from Thinkful's Front End Web Development course" | |
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write JS code so when a user clicks on one of the | |
// thumbnail images, that image should be displayed | |
// in the full size image container at the top. | |
// ********* MY ANSWER ************ | |
$(function() { | |
$('.thumbnail').click(function(event) { | |
$('.hero, img').attr(); | |
$('.hero').append( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getTokens(rawString) { | |
// NB: `.filter(Boolean)` removes any falsy items from an array | |
// method '.toLowerCase' makes all the characters in the string 'rawString' smallcaps | |
// method '.split' splits each item in the string with the characters passed | |
// method '.sort()' will sort the string alphabetically | |
return rawString.toLowerCase().split(/[ ,!.";:-]+/).filter(Boolean).sort(); | |
} | |
function mostFrequentWord(text) { | |
// locally creating a variable 'words' that calls the function getTokens passing the argument on this function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var obj1 = { | |
key1: 1, | |
key2: 'Value2', | |
key3: 3, | |
key4: 'Value4' | |
} | |
var obj2 = { | |
key1: 1, | |
key2: 'Value2', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write a function called enrollInSummerSchool that takes a single argument, students. | |
// students is an array of objects, with each object representing a student — | |
// for example, {name: 'Tim', status: 'Current student', course: 'Biology'}. | |
// enrollInSummerSchool should return an array of objects. | |
// For each object from the original array, it should return the original name and course, | |
// but should update the status to In Summer school. | |
function enrollInSummerSchool(students) { | |
var results = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create My Object Drill | |
// Write a function that returns an object with key/value pairs: foo=>bar, answerToUniverse=>42, olly olly=>oxen, and | |
// sayHello=> function that returns the string 'hello' | |
function createMyObject() { | |
return myObject = { | |
foo: 'bar', | |
answerToUniverse: 42, | |
'olly olly': 'oxen free', |
NewerOlder