This file contains hidden or 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 numberToEnglish = n => { | |
| //handle exceptions; zero, >/< prescribed range, non-integers | |
| if (n === 0) | |
| return 'zero'; | |
| if (n < 0 || n > 99999) | |
| return ''; | |
| let strn = String(n).padStart(5,'0'); //convert to uniform, five digit string | |
| if (strn.includes('.')) | |
| return ''; | |
| //get strings for thousands, hundreds, and tens |
This file contains hidden or 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 buildGraph(edges) { | |
| let graph = Object.create(null); | |
| function addEdge(from, to) { | |
| if (graph[from] == null) { | |
| graph[from] = [to]; | |
| } else { | |
| graph[from].push(to); | |
| } | |
| console.log(from, to); | |
| console.log(graph[from]); //vs console.log(graph); why does printing the entire graph here print the completed graph on the second call, even though it shouldn't be fully constructed until the last call? |
This file contains hidden or 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
| utils.throttle = (func, delay) => { | |
| function throttledFunc(...args) { | |
| setTimeout(function () { | |
| func(...args) | |
| }, delay); | |
| } | |
| return throttledFunc; | |
| }; | |
| module.exports = utils; |
This file contains hidden or 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 chai = require('chai'); | |
| const expect = chai.expect; | |
| const chaiThings = require('chai-things'); | |
| const chaiSpies = require('chai-spies'); | |
| const sinon = require('sinon'); | |
| chai.use(chaiThings); | |
| chai.use(chaiSpies); | |
| // Models | |
| const db = require('../server/models'); |