Devtools Tech is a free platform for Frontend Engineers. It takes a lot of time, effort, and finanical resources to keep the platform running. If you see any value in our work and would like to support us then you can do using the following options.InternationalDomestic
In this question, you need to implement the following code so that when the interviewer calls
then the following HTML structure as a string with proper indentation should be returned.
You can also optionally print the output in the console along with returning it.
IMPORTANT: You cannot use actual DOM APIs. You need to implement everything on your own.
const vDocument = new VDocument(); const body = vDocument.createElement("body"); const div = vDocument.createElement("div"); div.innerHTML = "Hello, I am a div!"; body.appendChild(div); vDocument.appendChild(body); // proper html structure const html = vDocument.render();
<html> <body> <div> Hello, I am a div! </div> </body> </html>
You can use spaces or tabs to indent your output. However, test cases check for multiples of
4 spaces per tag level.
This question is designed to test various important topics like OOPS, Inheritance, Candidate's problem solving skills, understanding of DOM, how well the candidate can structure code. So, try to write as clean code as possible.
You can check our answer here.
Start the timer and try to finish as soon as possible. You can record your solving process or take a screenshot of your final code and share it on Twitter/LinkedIn and tag @devtoolstech