","answerCount":1,"datePublished":"2026-10-10T03:20:41.671Z","author":{"@type":"Organization","name":"PrimerPrep","url":"https://www.primerprep.in"},"acceptedAnswer":{"@type":"Answer","text":"Correct answer: p,a,s,s, ,%, ,f,a,i,l, ,%. This question has been retained as-is due to its unique context.","upvoteCount":1,"datePublished":"2026-10-10T03:20:41.671Z","author":{"@type":"Organization","name":"PrimerPrep","url":"https://www.primerprep.in"},"url":"https://www.primerprep.in/q/predict-the-output-of-the-following-javascript-codehtmlheads#answer"}}}
Essentials
primer-original-v2mediumEssentialsWeb Technologiesprimer-original-v2

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
p,a,s,s, ,%, ,f,a,i,l, ,%
B
JavaScript
C
HTML5
D
innerHTML

Correct answer: p,a,s,s, ,%, ,f,a,i,l, ,%

Detailed Solution & Conceptual Analysis

This question has been retained as-is due to its unique context.

Key Engineering Takeaway

In Essentials, understanding the underlying mechanics of Essentials is critical for writing performant, bug-free production code and passing rigorous technical architecture reviews.

Related Essentials questions

Practice more Essentials questions

PrimerPrep has independently reviewed practice questions and coding exercises — all free.