$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · hard · #114

What is logged?

const re = /a/g;
console.log(re.test('a'), re.test('a'));
  1. true false
  2. true true
  3. false true
  4. false false
A global regex keeps lastIndex between calls, so the second test starts past the match.
Play Problem Solving ▸