var str = 'Some very long string'; if(str.length > 10) str = str.substring(0,10);
var example = "I am too long string"; var result; // Slice is JS function result = example.slice(0, 10)+'...'; //if you need dots after the string you can add