From 5fb9be8335a4900c2ab313c55727b99513ca4934 Mon Sep 17 00:00:00 2001 From: hasinasunz <73208812+hasinasunz@users.noreply.github.com> Date: Fri, 4 Dec 2020 20:51:39 -0500 Subject: [PATCH] completed --- indexformula.html | 16 ++++++++++++++++ js/formulas.js | 41 +++++++++++++++++++++-------------------- 2 files changed, 37 insertions(+), 20 deletions(-) create mode 100644 indexformula.html diff --git a/indexformula.html b/indexformula.html new file mode 100644 index 0000000..d66c928 --- /dev/null +++ b/indexformula.html @@ -0,0 +1,16 @@ + + + + + Basic Formulas + + + +

Basic Formulas

+
    +
  1. Open Developer Tools
  2. +
  3. Select the Console Tab
  4. +
  5. Begin typing JS functions to test output
  6. +
+ + diff --git a/js/formulas.js b/js/formulas.js index 2435d53..39db953 100644 --- a/js/formulas.js +++ b/js/formulas.js @@ -1,80 +1,81 @@ // Basic math formulaas function addition(num1, num2){ - return -1; + return num1 + num2; } function subtraction(num1, num2){ - return -1; + return num1 - num2; + } function multiplication(num1, num2){ - return -1; + return num1 * num2; } function division(num1, num2){ - return -1; + return num1 / num2; } // Area formulaas function areaSquare(side){ - return -1; + return side * side; } function areaRectangle(length, width){ - return -1; + return length * width; } function areaParallelogram(base, height){ - return -1; + return base * height; } function areaTriangle(base, height){ - return -1; + return (1/2) * base * height; } function Circle(radius){ - return -1; + return Math.PI * radius * radius; } function Sphere(radius){ - return -1; + return 4 * Math.PI * radius * radius; } // Surface Area formulas function surfaceAreaCube(side){ - return -1; + return 6 * side * side; } function surfaceAreaCylinder(radius, height){ - return -1; + return 2 * Math.PI * radius * height + 2 * Math.PI * radius * radius; } // Perimeter formulas function perimeterSquare(side){ - return -1; + return 4 * side; } function perimeterRectangle(length, height){ - return -1; + return 2 * length + 2 * height; } function perimeterTriangle(side1, side2, side3){ - return -1; + return side1 + side2 +side3; } function perimeterCircle(diameter){ - return -1; + return Math.PI * diameter; } // Volume formulas function volumeCube(side){ - return -1; + return side * side * side; } function volumeRectangular(length, width, height){ - return -1; + return length * width * height; } function volumeCylinder(radius, height){ - return -1; -} + return Math.PI * radius * radius * height; +} \ No newline at end of file