","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.","upvoteCount":1,"url":"https://www.primerprep.in/q/predict-the-output-of-the-following-javascript-code-var-txt-pass-70#answer"}}}
Web Technology
Accenture Technical 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

Quick AnswerThe correct answer is True because it directly addresses the core logic of Web Technology.

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

PrimerPrep has 1400+ practice questions, 2026 simulations and coding hands-on — all free.

Watch Walkthroughs!