News for hackers. Stuff that matters.
Re:Tips for beginning systems and software engineers by wtbob on Thursday May 19, 2016 @09:30AM (#11730017)
This is simple:

    if (str.length < 6) {
      str = ' '.repeat(6-str.length) + str;
    }
This is easy:

    leftPad = require('left-pad')
 
    leftPad(str, 6)
(note: my JavaScript is rusty; there may be some very valid reason that the simple code is wrong)
Re:Tips for beginning systems and software engineers by collyw on Thursday May 19, 2016 @01:03PM (#11731675)
Thats one reason that its tempting to use something as simple as left pad. I only spend a small percentage of my time doing JavaScript, and the language has enough gotchas. Using something like that would give me the peace of mind that I haven't missed some quirk of the language. If someone knows how to publish a package on npm, then they probably know more JavaScript than me.