Skip to content

Instantly share code, notes, and snippets.

View awhit012's full-sized avatar

Alex White awhit012

View GitHub Profile
class StopWatch {
constructor() {
this.seconds = 0
this.timerId = null
this.startButton = document.getElementById("start")
this.pauseButton = document.getElementById("pause")
this.resetButton = document.getElementById("reset")
this.h1 = document.getElementsByTagName("h1")[0]
this.addEventListeners()
}
const http = require('http')
const books = [
{id: 1, title: "You Don't Know JS", author: "Kyle Simpson"},
{id: 2, title: "Sometimes a Great Notion", author: "Ken Kesey"},
{id: 3, title: "The Teachings of Don Juan", author: "Carlos Casteneda"}
]
// check the url, if it is /books or /books/:id
// check the method, if it is GET, POST, PUT, or DELETE
// depending on the above, we want to send back our response.
# GET
curl -v http://localhost:8080/code-snippets
# POST
curl -d '{"name": "my code snippet", "snippet": "( ()=> { return `HELLOOOOOOOOO!!!!!!`})()"}' -H 'Content-Type: application/json'   http://localhost:8080/code-snippets
# PUT
const alphabet = {
"a": 0,
"b": 1,
"c": 2,
"d": 3,
"e": 4,
"f": 5,
"g": 6,
"h": 7,
"i": 8,

Map

Objectives

  • Use .map() to mutate an array of objects
  • Articulate when it should be used over a 'for' or 'forEach' loop

Why?

In JavaScript we can always use for loops to iterate over arrays. However, arrays have many functions that can be performed on them that are more lexically clear. The .map function is designed for when we want to mutate items in an array and return a new, mutated array.

Proposal for Curriculum: Node + Express

This is a proposal for the creation of a text-based curriculum, using Markdown. Each lesson would include learning objectives, small code examples, and links to external resources. This proposal does not include full functioning "solution code", only code samples to demonstrate each concept.

This curriculum covers Node and Express as a JSON API, not as a full web application platform using something like Pug. It is a partner course to the React material, intended to enable users to use this backend to talk to a decoupled front end. The two courses together are not meant to be comprehensive. This does not cover, for example, how to enable CORS.

Unit I: Intro to Node