Beginner
Calculate the Area of a Rectangle
Description
In JavaScript, functions allow you to encapsulate reusable logic.
In this challenge, you will write a function that calculates the area of a rectangle.
The area of a rectangle is calculated using the formula: Area = length × width
Your task is to write a function named calculateRectangleArea that takes the length and width of a rectangle as input and returns its area.
Example Usage:
console.log(calculateRectangleArea(5, 10)); // Expected output: 50 console.log(calculateRectangleArea(3, 7)); // Expected output: 21 console.log(calculateRectangleArea(0, 10)); // Expected output: 0
Constraints:
- The input will always be two numbers (length and width).
- The function should return the area of the rectangle as a number.
- If either the length or width is 0, the area should be 0.
Did you know?
The first-ever website was created by Tim Berners-Lee for the internet.
Test Cases
Input:
5
Expected Output:
50