Javascript’s Unicode Problem
Disclaimer: A repost of my article for CafeDev A while ago I needed a simple string pad function, and since it’s a freakishly simple task, I just wrote a simple function: function limit(str, limit = 16, padString = "#", padPosition = "right") { const strLength = str.length; if (strLength > limit) { return str.substring(0, limit); } else if (strLength < limit) { const padRepeats = padString.repeat(limit - strLength); return (padPosition === "left") ? padRepeats + str : str + padRepeats; } return str; } Pretty simple, right? And it