Skip to content

Instantly share code, notes, and snippets.

/* Final Refactor */
// This is the final form of the function. I included the first iteration below to show my thought process as well as how the code was refactored
function flatten (arr) {
if (!Array.isArray(arr)) return -1;
return arr.reduce((p, c) => !Array.isArray(c) ? p.concat(c) : p.concat(flatten(c)), []);
}
/* End Final Refactor */
/* First Iteration - With Comments */
// Import scrollbar size helper
import scrollbarSize from 'dom-helpers/util/scrollbarSize';
// Helper function
adjusted (width, height) {
const {
columnWidth,
columnCount,