Tell us what’s happening:
Every other text have parsed and the textArea.textContent.value is red, yet the i am still getting this error.
- When the character count is 50, the text should be displayed in red
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" placeholder ="Character Count: 0/50"></textarea>
<p id ="char-count">Character Count: 0/50</p>
<script src ="script.js"></script>
</body>
</html>
/* file: styles.css */
/* file: script.js */
const textArea =document.getElementById("text-input")
const paragraph =document.getElementById("char-count")
textArea.addEventListener("input", () =>{
if(textArea.value.length > 50){
textArea.value = textArea.value.substring(0, 50);
textArea.style.outline = "none";
}
paragraph.textContent = `Character Count: ${textArea.value.length}/50`;
if(textArea.value.length === 50){
textArea.style.color = "red";
}else{
textArea.style.color = "black"
}
})
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36
Challenge Information:
Build a Real Time Counter - Build a Real Time Counter
https://www.freecodecamp.org/learn/full-stack-developer/lab-real-time-counter/build-a-real-time-counter