Skip to content

Instantly share code, notes, and snippets.

View bertiespell's full-sized avatar

Bertie bertiespell

View GitHub Profile
@bertiespell
bertiespell / server.js
Created December 23, 2018 19:11
A simple server that saves key/value pairs
var http = require('http');
const storedValues = {};
http.createServer((request, response) => {
// check path is supported
const path = request.url.split('?');
if (!path || path.length !== 2) {
response.writeHead(404);
@bertiespell
bertiespell / depthFirstSearch.js
Last active December 24, 2018 10:38
A depth first searching function :)
function depthFirstSearch(tree, searchTerm) { // accepts standard object
if (typeof searchTerm === 'number') {
searchTerm = String(searchTerm);
}
if (typeof searchTerm !== 'string') {
return null;
}
const objKeys = Object.keys(tree);