← Back to challenges

Area of a Rectangle

JavaScriptMediumalgebrageometrymath

Instructions

Create a function that calculates the area of a rectangle. If the arguments are invalid, your function must return -1.

Examples

area(3, 4) ➞ 12

area(10, 11) ➞ 110

area(-1, 5) ➞ -1

area(0, 2) ➞ -1

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Minimal I: If Boolean Then Boolean