This file contains 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
/* 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 */ |
This file contains 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
// Import scrollbar size helper | |
import scrollbarSize from 'dom-helpers/util/scrollbarSize'; | |
// Helper function | |
adjusted (width, height) { | |
const { | |
columnWidth, | |
columnCount, |