PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Other / Miscellaneous/LinkedIn

Implement map and render to DOM

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's skills in vanilla JavaScript utility implementation and DOM rendering, covering array and plain-object iteration semantics, higher-order functions, input validation, error handling, and safe text rendering for browser environments.

  • medium
  • LinkedIn
  • Other / Miscellaneous
  • Software Engineer

Implement map and render to DOM

Company: LinkedIn

Role: Software Engineer

Category: Other / Miscellaneous

Difficulty: medium

Interview Round: HR Screen

Using only vanilla JavaScript in a script tag, implement a function similar to Array.prototype.map (without using the built-in map) to transform a list (array or key–value dictionary) of objects. Then render one div per transformed item into the DOM with appropriate classes/attributes and handle empty/error states. Do not use any frameworks.

Quick Answer: This question evaluates a candidate's skills in vanilla JavaScript utility implementation and DOM rendering, covering array and plain-object iteration semantics, higher-order functions, input validation, error handling, and safe text rendering for browser environments.

Related Interview Questions

  • Explain HTTP verbs, CSS, and accessibility - LinkedIn (medium)
LinkedIn logo
LinkedIn
Sep 6, 2025, 12:00 AM
Software Engineer
HR Screen
Other / Miscellaneous
2
0

Build a Vanilla JS map-like Utility and DOM Renderer

Context

You are working in a basic browser environment with no frameworks or libraries. Implement a function that behaves like Array.prototype.map but must:

  • Not use the built-in map method.
  • Work for both arrays and plain key–value objects ("dictionaries").

Then use it to transform a list of objects into a render-friendly shape and render one div per transformed item into the DOM, with appropriate classes/attributes. Handle empty and error states.

Requirements

  1. Implement a map-like function that:
    • Accepts an input list (array or plain object), a callback, and an optional thisArg.
    • For arrays: iterates items (skipping holes) and returns a new array of mapped results.
    • For objects: iterates own enumerable keys and returns a new array of mapped results.
    • Validates inputs and throws a helpful error if misused.
  2. Implement a renderer that:
    • Renders one div per transformed item into a container in the DOM.
    • Applies classes and any attributes provided by the transformed items.
    • Uses safe text rendering (no innerHTML for untrusted data).
    • Shows an empty state if there are no items.
    • Shows an error state if something goes wrong.
  3. Use only vanilla JavaScript in a script tag. No frameworks.

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Other / Miscellaneous•More LinkedIn•More Software Engineer•LinkedIn Software Engineer•LinkedIn Other / Miscellaneous•Software Engineer Other / Miscellaneous
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.