
SHOW HN: Left-Pad could be the next FizzBuzz so we coded it up in 13 Languages - fahimulhaq
https://www.educative.io/collection/page/10370001/520001/750001
======
plugnburn
14 lines in JS? O'rly?

Even with such a strict check of the padding character length (with an
exception) and a period by default it's a four-liner at most.

    
    
      leftPad = (str, len, pd = '.') => {
          if(pd.length !== 1) throw 'Invalid input'
          else return Array(len > str.length ? 1+len-str.length : 0).join(pd) + str
      }

