← Bitkernel Interview Insights

Bitkernel·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Did a coding screen for a Software Engineer role at Bitkernel, basically one browser JavaScript question. Pretty straightforward but there were a couple of edge cases I had to think through carefully.

Questions Asked (1)

Q1

Implement a function `showPopupAndRedirect(message, targetUrl)` that shows a popup with the given message, then redirects to `targetUrl` after the user closes it. The redirect should only happen if `targetUrl` is a non-empty string. Use only vanilla JavaScript and built-in browser APIs.

Technical Trade-offsAPI & Integrations
Author's notes

My first instinct was just to use `alert(message)` and then set `window.location.href = targetUrl` right after.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and edge cases, then outline a simple implementation using window.alert for the popup and window.location.href for the redirect. Emphasize the guard condition to ensure redirect only occurs for a non-empty string targetUrl.

Pro tip: Mention that while alert is synchronous and simple, in a real app you might prefer a custom modal for better UX and testability; but for this constraint, alert is appropriate. Also, note that you should avoid using window.open for redirect as it may be blocked by popup blockers.

1. Clarify requirements and constraints

Confirm that the popup should be a blocking alert, and that redirect should only happen if targetUrl is a non-empty string. Ask about handling edge cases like null, undefined, or whitespace-only strings.

2. Design the function signature and logic

Define the function to accept message and targetUrl. Inside, show the popup with the message, then check if targetUrl is a non-empty string before redirecting.

3. Implement using built-in browser APIs

Use window.alert(message) to display the popup. After alert returns (user closes it), check typeof targetUrl === 'string' && targetUrl.trim() !== '' and then set window.location.href = targetUrl.

4. Consider edge cases and robustness

Handle cases where targetUrl is not a string, is empty, or contains only whitespace. Optionally, validate that targetUrl is a safe URL to prevent open redirect vulnerabilities.

5. Test and explain trade-offs

Mention testing with various inputs. Discuss trade-offs: alert is synchronous and simple but blocks the UI and is not customizable; a custom modal would be asynchronous and require a callback or promise.

Key Points to Mention

  • Use of window.alert for the popup, which is synchronous and blocks until dismissed.
  • Guard condition: check that targetUrl is a non-empty string (e.g., typeof targetUrl === 'string' && targetUrl.trim() !== '').
  • Redirect using window.location.href = targetUrl after the alert is closed.
  • Edge cases: null, undefined, empty string, whitespace-only string, non-string types.
  • Security consideration: validate targetUrl to prevent open redirect vulnerabilities (e.g., ensure it's a relative path or same-origin).
  • Trade-offs: alert is simple but blocks UI and is not customizable; custom modals are more flexible but asynchronous.

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