Google Interview Frontend Experience

UX Engineer early career recruited online is equivalent to a Frontend Engineer.
A guy greeted me and asked what kind of questions I wanted to work on, whether they are related to Frontend Engineering or normal ones (like leetcode), and I chose Frontend Engineering.
Q1:

<div id='1'>
    <span id='2'>Hello </span>
    <span id='3'>World </span>
</div>

Given the root element of a website and a string id, create a function to return an element by id. The element is unique, and you cannot use the built-in function getElementById().

Q2:

<div class='1'>
    <span class='2'>
        Hello
        <h1 class='3'>Giao</h1>
    </span>
    <span class='3'>World </span>
</div>

Given the root element of a website and a string class, create a function to return elements by class. There could be more than one node that has class = ‘3’, and you cannot use the built-in function getElementByClass();

Q1 requires returning a node, and Q2 requires returning an array. Both are not difficult, just basic DOM tree traversal. Good luck!