I am trying to convert this function but I can't seem to translate a few of the lines successfully.
$('.text').each(function() {
str = String($(this).html()); #this line
tot = str.length;
str = (tot <= max) ? str : str.substring(0,(max + 1))+"..."; #this line
$(this).html(str); #this line
});
How can I convert this into a javascript function?