Search⌘ K

The Usurper

Explore the JavaScript puzzle The Usurper by predicting its output. This lesson helps you sharpen your code reading skills, improve problem-solving, and deepen your understanding of JavaScript quirks.

We'll cover the following...

Puzzle code

Carefully read the code given below:

Javascript (babel-node)
// 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.

Technical Quiz
1.

What will be the output of the code above?

A.

24

B.

0

C.

16

D.

NaN


1 / 1

Let’s discuss this code and output together in the next lesson.