Build a Real Time Counter - Build a Real Time Counter

Tell us what’s happening:

6.If character count is greater than or equal to 50, the extra input should be trimmed.
I don’t know how to solve this problem, I mean I have a maxlength on my textarea, but I don’t think that’s how to solve this lab. Should I like store the input’s value and show it after each input? but that doesn’t make sense, can someone guide me to the answer. And by the way one more thing, is my code good? Or is it inefficient, I’m trying learn how to write good code, not code that’s bad but works

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>
    <link href="styles.css" rel="stylesheet">
</head>

<body>
    <h1>Real Time Counter</h1>
    <textarea placeholder="Type something" class="input" id="text-input" maxlength="50"></textarea>
    <p id="char-count">Character Count: <span class="count">0/50</span></p>
    <script src="script.js"></script>
</body>


</html>
/* file: styles.css */
*, *::after, *::before{
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

body{
  display: grid;
  place-content: center;
  height: 100vh;
  text-align: center;
}

textarea{
  resize: none;
  width: 300px;
  height: 100px;
  padding: 10px;
}
/* file: script.js */
const input = document.getElementById("text-input");
const para = document.getElementById("char-count");
let strCount = 0

input.addEventListener("input", () =>{
  strCount = input.value.length;
  updateCount(strCount);
});

function updateCount(num) {
  const count = document.querySelector(".count");
  let currCount = count.textContent.split("/")[0];
  currCount = num;
  count.textContent = `${currCount}/50`;
  if(currCount === 50){
    para.style.color = "red";
  }
}





Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36

Challenge Information:

Build a Real Time Counter - Build a Real Time Counter

Okay I found the solution, apparently slice for strings and arrays, here’s my new code:
removed by moderator

and I don’t know why I was turning my count into array and stuff like that, I could’ve just count.textContent = ${num}/50;

Congratulations on solving the challenge! You should be proud of your achievement…we are! But we are removing your working solution, so it is not available to others who have not yet done the work to get there. Again, congrats!