← Amazon Interview Insights

Amazon·Software Engineer·Online Assessment (OA)·Intermediate

IntermediatePrefer not to say
May 2026

Summary

Amazon SWE coding round with a frontend-flavored problem. Not what I expected from them but it was straightforward enough once I stopped overthinking the validation logic.

Questions Asked (1)

Q1

Build a form with Name, Phone, and Email fields that validates each input and appends a new row to an existing HTML table on success, or shows an error message if validation fails. Vanilla JS only, no libraries.

Technical Trade-offsAPI & Integrations
Author's notes

Spent way too long debating regex patterns for the phone field.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and edge cases, then outline a modular architecture with separate validation and DOM manipulation functions. Emphasize clean, maintainable code with robust validation and efficient DOM updates, and discuss trade-offs like inline vs. event delegation and regex vs. built-in validation.

Pro tip: Use event delegation for form submission and input events to improve performance and simplify dynamic row handling. Also, leverage the Constraint Validation API for built-in validation, but be prepared to explain when custom validation is necessary.

1. Clarify Requirements and Edge Cases

Ask about validation rules (e.g., phone format, email format), error display (inline vs. summary), and whether the table already has a specific structure. Consider edge cases like duplicate entries, empty fields, and international formats.

2. Design the HTML Structure

Create a form with labeled inputs for Name, Phone, and Email, each with an associated error message container. Ensure the table has a <tbody> for appending rows and appropriate headers.

3. Implement Validation Logic

Write validation functions for each field: Name (non-empty, alphabetic), Phone (regex for digits, optional formatting), Email (regex or built-in email validation). Return boolean and error messages.

4. Handle Form Submission and DOM Updates

On submit, prevent default, validate all fields, display errors if any, else create a new <tr> with <td>s for each value and append to <tbody>. Clear form and errors on success.

5. Optimize and Discuss Trade-offs

Mention event delegation, input event for real-time validation, and performance considerations. Discuss trade-offs between inline validation and on-submit validation, and between regex and built-in validation.

Key Points to Mention

  • Use of event.preventDefault() to stop form submission and handle via JS.
  • Validation techniques: regex for phone/email, trim() for whitespace, and built-in HTML5 validation attributes.
  • Error handling: displaying messages next to fields, clearing on input, and accessibility (aria-live).
  • DOM manipulation: creating elements with document.createElement, setting textContent to avoid XSS, and appending to tbody.
  • Event delegation: attaching a single listener to the form or table for efficiency.
  • Trade-offs: client-side vs. server-side validation, regex complexity vs. maintainability, and real-time vs. on-submit validation.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.