Limit text length in a database repeater not working with pagination

I know this is old, but this is my solution to this problem:


var characterlimit = 50; 
  $w("#myrepeater").forEachItem( ($item, itemData, index) => {
  let x = $item("#repeaterelement").text; //gets the text 
  let arr = x.split(" "); //parses the paragraph by space into an array 
  console.log(arr.slice(0, characterlimit));