Ask your AI Ask your AI to turn this code into a guided bug-finding exercise.
Claude ChatGPT I am reading "A search term must be treated as literal text inside a larger Node 24 pattern. What should the code do?" on CodeWiki (https://codewiki.com/practice/mcq/javascript/regexp/escape-dynamic-literal/).
Context (verbatim from the page):
"""
A search term must be treated as literal text inside a larger Node 24 pattern. What should the code do?
Insert RegExp.escape(term) into the pattern source.
Insert term directly and add the i flag.
Apply encodeURIComponent(term) before insertion.
Wrap term in a capturing group; parentheses make it literal.
"""
Introduce three subtle bugs into the example above and let me find them. Reveal each answer only after I have guessed.
Answer in English. Keep code examples in JavaScript. Where you are unsure, say so.