Shortened Text in Repeater

This is a question posted many times so i have tried to follow the guidance. This code does not work for me and i feel like i need to declare the field as an itemData or something and possibly disconnect the text element from the repeater?But this code seems to work for others

$w.onReady( function () {
$w(“#dataset1”).onReady( function () {
const shortTextLength = 40;
let fullText;
let shortText;
$w(“#repeater1”).forEachItem(($w,item) => {
fullText = $w(‘#dataset1’).getCurrentItem().answer;
if (!fullText.length) {
$w(‘#text67’).collapse();
} else
if (fullText.length <= shortTextLength) {
$w(‘#text67’).text = fullText;
} else {
shortText = fullText.substr(0, shortTextLength) + “…”;
$w(‘#text67’).text = shortText;
}
})
});
});

Thanks
Adam

Have a look at Nayeli (Code Queen) example here as it might be want you are after.
https://support.totallycodable.com/en/article/limit-characters-in-a-repeater-using-wix-code
Limit Characters using Wix Code in a Repeater | Load More Button - Youtube video about example

Thanks @givemeawhisky Nayeli’s code tutorial is super simple and very helpful. Thanks to you both.