Truncating text fields in Collection output displays

You have entered 5 instead of 0 here:

var trimmedString = string.substring(5, length); //should be 0

Doing this will only show the first 5 characters:

var length = 5; //number of characters

Assuming that dataset1 is the name of the dataset connected to your repeater, have you done this?

Resources for JS:
JavaScript | MDN
https://www.javascript.com/
JavaScript Tutorial
JavaScript Tutorial - Learn JavaScript