Skip to content

Instantly share code, notes, and snippets.

View adityatejas's full-sized avatar

Aditya Tejas adityatejas

View GitHub Profile
@adityatejas
adityatejas / truncateString.js
Last active June 20, 2016 15:59
Truncate a string
function truncateString(str, num) {
// Clear out that junk in your trunk
var truncatedStr = '';
if (str.length > num) {
truncatedStr = str.slice(0, num-3) + "...";
return truncatedStr;
}
else if (str.length <= 3)