This code written in JavaScript for Node.js finds open time blocks, given a set of intervals which are not available.
Node.js 5.x or higher is needed in order to run the code as it takes advantage of ES6 features and uses CommonJS modules. However, it can be run in a modern browser by removing the module.exports
line at the end of the file team_availability.js.
To run the tests, save both JavaScript files in the same directory and run node test.js
from the directory in a terminal/command prompt. The tests simply show expected and calculated results. In order to keep things simple, no external library for testing was used. Therefore, there are no asserts, expects, shoulds or anything like that. Just simple console output.