The Usurper
Test your JavaScript programming skills by solving the given puzzle about function overloading.
We'll cover the following
Puzzle code
Carefully read the code given below:
// Calculate the area of a rectanglefunction calculateArea(length, width) {return length * width;}// Calculate the area of a squarefunction calculateArea(length) {return length * length;}console.log(calculateArea(4, 6));
Your task: Guess the output
Try to guess the output of the above code. Attempt the following quiz to assess your understanding.
Q
What will be the output of the code above?
A)
24
B)
0
C)
16
D)
NaN
Let’s discuss this code and output together in the next lesson.