Tell us what’s happening:
My code does not pass the 6th test. I’ve used maxlength,readonly and disabled properties and its still failing
Your code so far
<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Real Time Counter</title>
</head>
<body>
<textarea id="text-input"></textarea>
<p id="char-count">Character Count: 0/50</p>
<script src="./script.js"></script>
</body>
</html>
/* file: styles.css */
/* file: script.js */
const textInput = document.getElementById("text-input")
const textCount= document.querySelector("#char-count")
function inputCount(){
textInput.maxLength = 50
const noInput = textInput.value.split("")
let sum = 0
for (let i =0; i < noInput.length; i++){
sum++
}
textCount.innerText = `Character Count: ${sum}/50`
if (sum >= 50){
textCount.style.color = "red"
noInput.length = 50
}
return textCount
}
textInput.addEventListener("input", inputCount)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Challenge Information:
Build a Real Time Counter - Build a Real Time Counter