I'm trying to limit the number of characters with JavaScript when the screen is in mobile mode but I don't know what I could be doing wrong. I'm new to the area and I have this question.
Follow the JavaScript code
<script>
const descricaoScript = document.querySelectorAll('#descricao-script')
const LIMIT = 135
function cartersLimit() {
for (let words of descricaoScript) {
const aboveLimit = words.innerText.length > LIMIT
const dotOrEmpty = aboveLimit? '...' : ''
words.innerText = words.innerText.substring(0, LIMIT) + dotOrEmpty
}
}
if(document.body.clientWidth < 440) {
cartersLimit === true
} else {
cartersLimit === false
}
</script>