What’s the most efficient way to check if a JavaScript string has special characters? I am trying to use a loop and checking various characters, but that does not seem very efficient, nor does it catch all characters.
Specifically, the goal is to check if a string contains any characters except A-Z, and 0-9, excluding Q and R.
Look into using a regular expression and the
.test()method..test():RegExpmay also be helpful, but it’s not a standard.Regular Expression Cheat Sheet