Yup, I was super confused when I first encountered this error. I found it making some unit tests for work, and lost a bit of time trying to figure it out... just for the issue to be a silly little flag xD
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Got it! Because
.test()
tests the rest of the string when the g flag is enabled!Just remove the g flag to fix
There you go, you found it!! Kinda weird if you don't expect that behaviour right?
It is! I never knew that till today!
Nice that's wonderful! That's what I aim this series to be, so I'm glad you learned something new!
I also didn't know this. It's probably very useful when building a parser, but when you don't expect it, it's a super confusing error 😖
Yup, I was super confused when I first encountered this error. I found it making some unit tests for work, and lost a bit of time trying to figure it out... just for the issue to be a silly little flag xD