The code uses '=' which is assignment, not comparison, causing a bug.
Step 2: Use strict equality '===' for comparison in JavaScript
Replace '=' with '===' to correctly compare values in the if condition.
Final Answer:
Use '===' instead of '=' in the if condition -> Option A
Quick Check:
Comparison needs '===' not '=' [OK]
Hint: Use '===' for comparison, '=' is assignment [OK]
Common Mistakes:
Confusing assignment '=' with comparison '==' or '==='
Removing await which is needed
Changing response type unnecessarily
5. You want to protect a private Astro page so only logged-in users can see it. Which server-side approach is best to check authentication before rendering?
hard
A. Render the page fully and then ask for login
B. Check a JavaScript variable on the client to hide content
C. Use client-side localStorage to store login status
D. Check a session cookie on the server and redirect if missing
Solution
Step 1: Understand server-side protection needs
Server must verify user identity before sending private content to prevent unauthorized access.
Step 2: Use session cookies for authentication
Session cookies are sent with requests and can be checked on the server to confirm login status.
Final Answer:
Check a session cookie on the server and redirect if missing -> Option D
Quick Check:
Server checks session cookie before rendering [OK]
Hint: Always verify login on server before showing private pages [OK]
Common Mistakes:
Relying on client-side checks only
Using localStorage which can be manipulated
Rendering private content before login check
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.