It is the same thing with prompt or confirm and if an "a" take place of s !
In short (See this
MDN page *) you have to restore the regexPattern.lastIndex to 0 before each new test !
Good to know. Thanks !
(*) Or better
ECMAScript Language Specification 15.10.6.2 and 15.10.6.3