var text = "blahalhahkanhklanlkanhlanlanhak"; var count = 35; var result = text.slice(0, count) + (text.length > count ? "..." : "");