Skip to content

Instantly share code, notes, and snippets.

// Bonfire: Truncate a string
// Author: @orelovo
// Challenge: http://www.freecodecamp.com/challenges/bonfire-truncate-a-string
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function truncate(str, num) {
var newStr = "";
if (num >= str.length)
newStr = str;
else if (num <= 3)