","text":"Predict the output of the following JavaScript code: ","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Correct answer: True. The \\D regex matches any non-digit character. Applied globally to \"pass 70% fail 30%\", it returns all letters, spaces, and symbols. The output will be an array of non-digit characters joined by commas when written to the document.","url":"https://www.primerdumps.in/q/predict-the-output-of-the-following-javascript-code-var-txt-pass-70"}}}
Web Technology
Accenture PrimereasyWeb TechnologyJavascript

Predict the output of the following JavaScript code: <html> <head> <script> var txt= "pass 70% fail 30%"; var pattern = /\D/g; var res= txt.match(pattern); document.write(res); </script> </head> </html>

Answer options

A
True
B
False

Correct answer: True

Explanation

The \D regex matches any non-digit character. Applied globally to "pass 70% fail 30%", it returns all letters, spaces, and symbols. The output will be an array of non-digit characters joined by commas when written to the document.

Related Accenture Web Technology questions

Practice more Accenture Web Technology questions

PrimerDumps has 1400+ primer questions, 2026 mocks and coding hands-on — all free.