The Usurper

Test your JavaScript programming skills by solving the given puzzle about function overloading.

Puzzle code

Carefully read the code given below:

Press + to interact
// Calculate the area of a rectangle
function calculateArea(length, width) {
return length * width;
}
// Calculate the area of a square
function 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.