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 ...
Markdown supported · ⌘↵ to post
No responses yet.