← Ramp Interview Insights

Ramp·Frontend Engineer·Take-home Assignment·Intermediate

Intermediate
May 2026

Summary

Ramp frontend take-home where the task was to retrieve a hidden flag value from either a DOM fixture or a URL response. Pretty niche challenge, more about knowing your browser APIs than anything algorithmic.

Questions Asked (1)

Q1

Given either a DOM page fixture with a hidden flag in the markup or a URL whose response contains the flag, write code that retrieves the flag value from whichever source is present and returns it as a string.

API & IntegrationsTechnical Trade-offs
Author's notes

The tricky part is covering both paths in one implementation.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the two possible sources and the expected return type, then design a single function that checks for the DOM fixture first (since it's synchronous and local) and falls back to fetching the URL if the DOM flag is absent. Use a clean async/await pattern with proper error handling and return the flag as a string.

Pro tip: Mention that you would write unit tests for both scenarios and use a timeout or AbortController for the fetch to avoid hanging requests—this shows production awareness beyond just solving the puzzle.

1. Clarify requirements and inputs

Ask whether the DOM fixture is always present or optional, and whether the URL is a fallback or independent. Confirm that the function should return a string and handle errors gracefully.

2. Design the detection logic

Decide on a reliable selector or attribute to find the hidden flag in the DOM (e.g., data-flag, hidden input, or meta tag). For the URL, plan to fetch and parse the response (e.g., JSON, text, or regex).

3. Implement the retrieval function

Write an async function that first checks the DOM for the flag; if not found, fetches the URL and extracts the flag. Use try/catch to handle network errors and return null or throw a meaningful error.

4. Handle edge cases and security

Consider cases where both sources are present (prioritize DOM), neither is present (return null or throw), and sanitize the flag to prevent XSS if injecting into DOM. Use AbortController for fetch timeout.

5. Test and validate

Write unit tests mocking the DOM and fetch to verify both paths. Ensure the function returns a string and handles asynchronous behavior correctly.

Key Points to Mention

  • Use of async/await for clean asynchronous code
  • DOM querying with querySelector and data attributes
  • Fetch API with error handling and timeout
  • Prioritization logic: DOM first, then URL fallback
  • Return type consistency: always a string or null
  • Security considerations: sanitizing the flag and avoiding XSS

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