Short text in repeater with '...'

Hii
I’m trying to make the text that appears on my website in the repeater part shorted (like a resume, with a specific number of words appearing and then ‘…’ ), but the code I’m using (I’ve already tried other ways), doesn’t work at all. I put it in normal text format, but in the Dataset is in a TAG format, I don’t know if that influences in anyway.

Code used:

$w.onReady(function () {

$w("#dynamicDataset").onReady(function () {

const shortTextLength = 10;
let fullText;
let shortText;

   $w("#repeater1").forEachItem(($w,item) => {

        fullText = $w('#dynamicDataset').getCurrentItem().answer;

        if (!fullText.length) {
            $w('#categoria').collapse();
        } else
        if (fullText.length <= shortTextLength) {
            $w('#categoria').text = fullText;

        } else {
            shortText = fullText.substr(0, shortTextLength) + "...";
            $w('#categoria').text = shortText;
        }

    })

});

});