PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Bitkernel

Implement popup and redirect in JavaScript

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency with client-side JavaScript, including browser APIs, DOM-based UI creation for popups, event handling, navigation mechanisms, and simple input validation for redirects.

  • hard
  • Bitkernel
  • Coding & Algorithms
  • Software Engineer

Implement popup and redirect in JavaScript

Company: Bitkernel

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Take-home Project

You are working in a browser environment and must use **vanilla JavaScript only** (no external libraries). ### Task Implement a function `showPopupAndRedirect(message, targetUrl)` that does the following: 1. Immediately shows a popup dialog to the user displaying the given `message`. 2. After the user closes the popup, the current page should redirect to `targetUrl`. ### Requirements - The popup must be created using only built-in browser APIs (for example, `alert`, `confirm`, or a custom DOM-based modal that you implement yourself). - The redirect must be done using standard browser navigation (e.g., assigning to `window.location` or a similar mechanism). - If `targetUrl` is not a non-empty string, the function should **not** attempt to redirect. - Assume this code runs in a modern browser with JavaScript enabled. You do **not** need to handle errors beyond the simple validation of `targetUrl` described above. Describe the implementation and then provide the JavaScript code for `showPopupAndRedirect`.

Quick Answer: This question evaluates proficiency with client-side JavaScript, including browser APIs, DOM-based UI creation for popups, event handling, navigation mechanisms, and simple input validation for redirects.

Bitkernel logo
Bitkernel
Oct 3, 2025, 12:00 AM
Software Engineer
Take-home Project
Coding & Algorithms
1
0

You are working in a browser environment and must use vanilla JavaScript only (no external libraries).

Task

Implement a function showPopupAndRedirect(message, targetUrl) that does the following:

  1. Immediately shows a popup dialog to the user displaying the given message .
  2. After the user closes the popup, the current page should redirect to targetUrl .

Requirements

  • The popup must be created using only built-in browser APIs (for example, alert , confirm , or a custom DOM-based modal that you implement yourself).
  • The redirect must be done using standard browser navigation (e.g., assigning to window.location or a similar mechanism).
  • If targetUrl is not a non-empty string, the function should not attempt to redirect.
  • Assume this code runs in a modern browser with JavaScript enabled.

You do not need to handle errors beyond the simple validation of targetUrl described above.

Describe the implementation and then provide the JavaScript code for showPopupAndRedirect.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Bitkernel•More Software Engineer•Bitkernel Software Engineer•Bitkernel Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.