C. sendPasswordResetEmail is not a Firebase method
D. No internet connection
Solution
Step 1: Check method call syntax
The code calls firebase.auth.sendPasswordResetEmail without parentheses after auth, which is incorrect.
Step 2: Understand correct usage
The correct call is firebase.auth().sendPasswordResetEmail(email) because auth is a function that returns the auth object.
Final Answer:
Missing parentheses after auth() -> Option B
Quick Check:
auth() must be called as a function [OK]
Hint: Always call auth() with parentheses before methods [OK]
Common Mistakes:
Omitting parentheses after auth
Assuming method names are wrong
Ignoring syntax errors
5. You want to implement a password reset flow that shows a success message only if the email was sent, and an error message otherwise. Which code snippet correctly achieves this?
hard
A. firebase.auth().sendPasswordResetEmail(email)
.then(() => alert('Failed to send email'))
.catch(() => alert('Reset email sent'))
B. firebase.auth().sendPasswordResetEmail(email)
.catch(() => alert('Reset email sent'))
.then(() => alert('Failed to send email'))
C. firebase.auth().sendPasswordResetEmail(email)
.then(() => alert('Reset email sent'))
.catch(() => alert('Failed to send email'))
D. firebase.auth().sendPasswordResetEmail(email)
.finally(() => alert('Reset email sent'))
Solution
Step 1: Understand promise handlers order
The then handler runs on success, and catch runs on failure.
Step 2: Match messages to handlers
Success should show 'Reset email sent', failure should show 'Failed to send email'. Only firebase.auth().sendPasswordResetEmail(email)
.then(() => alert('Reset email sent'))
.catch(() => alert('Failed to send email')) matches this logic correctly.
Final Answer:
firebase.auth().sendPasswordResetEmail(email)
.then(() => alert('Reset email sent'))
.catch(() => alert('Failed to send email')) -> Option C
Quick Check:
then() = success, catch() = error [OK]
Hint: Use then() for success, catch() for errors [OK]
Common Mistakes:
Swapping then and catch handlers
Using finally for success message
Showing error message on success
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.