Question 3
Back to Exercise
JavaScript refuses to run the code below. Which statement correctly describes the problem?
const re = /hello/ix;
console.log(re.test("HELLO"));
- A It prints true
- B It prints false
- C SyntaxError: x is not a valid JavaScript regex flag (valid flags are d, g, i, m, s, u, v, y) Correct
- D The x flag is ignored
Correct Answer: Option C
Some other languages support an x (extended) flag; JavaScript does not, and an invalid flag in a literal is an early error.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!