Sometimes, the elegant implementation is just a function. Not a method.  Not a  class. Not a framework.  Just a function.

- John Fucking Carmack

 

const range = (start, end) => {
    const result = [];
    for(let i = start; i <= end; i ++) {
        result.push(i)
    }
    return result
}
const leftPad = (spacer, indent, str) => {
    return range(1, indent).reduce((a, _) => spacer + a, str)
}
Made with Slides.com