Shave extra characters from text with one line of code
This code is inspired from ShaveJS and uses that approach in one line.
First of all, here's the code in one line.
const shave=(s, n)=>(s.length>n) ? s.substr(0, n-2)+'..' : s;
This function takes two parameters, string and length. Then truncates (or ...
rexwebmedia.hashnode.dev1 min read