I’m failing tests 4 through 6:
4. When the #text-input element contains the text hello coder the #char-count element should contain the text “Character Count: 11/50”
5. When the character count is 50, the text should be displayed in red.
6. If character count is greater than or equal to 50, the user shouldn’t be able to enter more characters.
I’ve tested each of these scenarios in my program and I believe my program meets each of these requirements. I reviewed the forum and saw several posts about the greater than 50-character issue and attempted to solve it with a slice, but that’s not working either. Any help is appreciated. Thanks in advance.
Thank you. I switched ‘keyup’ to ‘input’ and I’m now passing tests 1-5, but still not passing test 6. Other than the event change, my JS is the same.
I try to handle the greater than 50-character issues using an array slice and a maxlength on the text area but that isn’t working. Any hint on how to pass this final test?
Here is my new JS. The HTML and CSS are the same as above.
@fcc4b6d10c4-b540-4e2 Thank you for that. I was confusing array.slice vs string.slice and they are very different.
@MostafaElbadry I don’t understand. Having a maxlength blocks additional input per the requirements. I agree with you that removing it allows more than 50 characters. But I’m confused why I would remove it since the result is the opposite of the requirements, right?
Despite not understanding why, I did follow your advice and removed the maxlength. I rewrote my JS. It appears to work property but I’m still not passing the tests. Any advice on how to make the JS pass the test? My JS now looks like this:
The first index is inclusive, the second index is not. . After fixing the slice function, I was able to pass the test. Thank you for your help and patience.