diff --git a/docs/archive.html b/docs/archive.html index 60e0381a7..73dc1a481 100644 --- a/docs/archive.html +++ b/docs/archive.html @@ -136,6 +136,11 @@ ); };
fibonacciUntilNum(10); // [ 0, 1, 1, 2, 3, 5, 8 ] +
Returns the area of a triangle using only the 3 side lengths, Heron's formula. Assumes that the sides define a valid triangle. Does NOT assume it is a right triangle.
More information on what Heron's formula is and why it works available here: https://en.wikipedia.org/wiki/Heron%27s_formula.
Uses Math.sqrt() to find the square root of a value.
const heronArea = (side_a, side_b, side_c) => { + const p = (side_a + side_b + side_c) / 2 + return Math.sqrt(p * (p-side_a) * (p-side_b) * (p-side_c)) + }; +
heronArea(3, 4, 5); // 6
Returns the number of times num can be divided by divisor (integer or fractional) without getting a fractional answer. Works for both negative and positive integers.
If divisor is -1 or 1 return Infinity. If divisor is -0 or 0 return 0. Otherwise, keep dividing num with divisor and incrementing i, while the result is an integer. Return the number of times the loop was executed, i.
const howManyTimes = (num, divisor) => { if (divisor === 1 || divisor === -1) return Infinity; if (divisor === 0) return 0;