← Back to challenges

Find the Area of a (Regular) Hexagon

JavaScriptHardalgorithmsmathgeometry

Instructions

Given the side length x find the area of a hexagon.

Formula to find the area of a hexagon

Examples

areaOfHexagon(1) ➞ 2.6

areaOfHexagon(2) ➞ 10.4

areaOfHexagon(3) ➞ 23.4

Notes

  • Return null if the side length given is not a positive integer.
  • Round to the nearest tenth.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: The Modulus Operator Function