Reply to post: this can be simplified alot...

How one developer just broke Node, Babel and thousands of projects in 11 lines of JavaScript

Pwnball

this can be simplified alot...

First off.. whats with all the "z n ch" etc variables? its 2017 for crying out loud, IDE's have been taking care of us for years.. there is zeros (pun intended) reason to shorten variables like that.

function padLeft(originalValue: string, width: number, character: string) {

character = character || '0';

return originalValue.length >= width ? originalValue : new Array(width - originalValue.length + 1).join(character ) + originalValue;

}

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Biting the hand that feeds IT © 1998–2019