Challenge: Is a Child?
This challenge will test your skills in implementing DOM related functions to find if one element is the child of another.
We'll cover the following
Problem statement #
In this challenge, you need to implement the function isChild
which checks whether one element is the child of another. It should return true
if the element is a child and false
otherwise.
Carefully study the HTML file before implementing the function in JavaScript.
Input #
A parent
and child
passed to isChild
Output #
A Boolean value
Sample input #
<html>
<head>
</head>
<body>
<button id="myButton">Check</button>
<button id = "myButton2">Click</button>
</body>
</html>
var parent = document.getElementById("myButton")
var child = document.getElementById("myButton2")
isChild(parent,child)
Sample output #
false
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.