Skip to content

Instantly share code, notes, and snippets.

@zubaird
zubaird / CRUD Drills
Last active September 3, 2020 15:02
# Server Side Practice Assessment
## What to do
To begin, you will need to fork and clone down this repository and build a RESTful API from scratch based on the specifications below.
Demonstrate that you can create an ExpressJS server, use RESTful convention, and connect the server to a properly created database.
## Specifications
/* HINT: */
/* Use command + / to quickly comment/uncomment highlighted lines of code */
/* Basic Higher Order Function that takes a callback function in as a parameter */
function callLater(functionAsParameter){
functionAsParameter() // <---- called a callback function because it's passed in to the outer function "callLater" and only called when the outer function is called
}

Problem solving for whiteboard interviews

Problem solving is a core skill for software engineers. Whether you are debugging something in a code base, or working through an interview challenge, you will need to have a plan in place for how to approach the problem. Without one, you may find yourself quickly getting stuck or distracted by unrelated issues. Worse - during an in-person interview, you might find it difficult to stay on track, focused and able to scope the problem. Having a well rehearsed process will help you come accross as confident and professional.

The problem solving process is based on mathematician George Pólya's technique read more

Most the details will be specific to whiteboarding problems, but the general technique can be used for any problem solving scenario

If this technique fails, Pólya advises "If you can't solve a problem, then there is an easier problem you can solve: find it." Or: "If you cannot solve the proposed problem

Full Stack Drills

Please read all the directions in this readme.

Part 1: Server API

(Goal time: 45 minutes)

  • Complete the server within the allotted goal time.
/**
*
* Implement a `map` method on this Tree class, using pseudoclassical instantiation.
*
* Map accepts a mapping function as its only argument. It traverses the tree,
* passing each node's value into the mapping function, and generates a new
* tree containing the results.
*
* So `map` should return a tree with the same structure, and different values,
* but it should NOT modify the tree that was passed in.

Objects and Arrays Exercises

Take each variable, paste it into repl.it at the top of the file. Access the specified location, put it into a seperate variable. Console.log that variable, and make sure it matches the prompt.

Array Access

  1. Given the following array:

Adding Angular to Express

With our ExpressJS app we just need to make a few more changes and we're ready to add angular!

We'll use a single index page on the server-side to contain all of the angular views.

Make a root path to go to a newly created index.ejs page, and update the routes we have to follow the path localhost:3001/api/icecreams . . .

the changes should look like this, server.js:

Routing and Postman

For this section, we'll need to install Postman so that we can test out our routes. Click the image link below.

In the website click the 'get it now' button and add it to you Chrome browser.

Routing

Express Setup

In this unit, we'll be building an AngularJS app on top of Node and Express:

Frontend

  • AngularJS
  • Bootstrap

Backend

Angular Custom Directive: Caffeine Meter

In this exercise, we're going to revisit the angular tea shopping cart and create a custom directive to graphicaly display the ammount of caffeine in each tea.

The caffeine display should look something like this:

The code should look someting like this: