hardMultiple ChoiceObjective-mapped
FC0-U71 Practice Question: A web application uses a JavaScript function to…
A web application uses a JavaScript function to validate user input on a registration form. The function checks that the password is at least 8 characters long and contains a number. When a user submits the form with a password "abc123", the validation passes even though the password has only 6 characters. The developer examines the code and finds that the function uses the condition: if (password.length >= 8 || /\d/.test(password)). Which logical error is causing this bug?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
The condition uses OR instead of AND.
The condition uses OR (||) instead of AND (&&), so the validation passes if either condition is true. "abc123" has a number, so it passes. The regular expression is correct, length check is appropriate, and the function is called.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
The condition uses OR instead of AND.
Why this is correct
Using OR means only one condition needs to be true; with AND both must be true.
- ✗
The function is not called.
Why it's wrong here
If the function weren't called, no validation would occur; but validation passes for this input, so it is called.
- ✗
The regular expression is incorrect.
Why it's wrong here
The regex /\d/ correctly checks for a digit.
- ✗
The length check is incorrect because it uses >= instead of >.
Why it's wrong here
>= is correct for 'at least 8' because it includes 8.
Go deeper
Related to this question
About these practice questions
This FC0-U71 question is part of Courseiva's 988-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This FC0-U71 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the FC0-U71 exam.