Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions RR-JS-Basics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Work Assignment - JavaScript Basics

## Tech Stack
A list of expected technology to be used in this assignment

* IDE
* JavaScript
* Terminal
* Git
* Web Browser

## Assignment
Using your knowledge of javascript basics, complete the provided methods to return the proper values. Use the browser Development Tools to run the commands

## Requirements

Several functions have been provided for you in the JavaScript document. You must provide the logic to complete the function.

The formulas are divided into 5 sections:

### Basic Math

| Formula | Equation | Description |
| ------- | -------- | ----------- |
| Addition | a + b | a & b are any real number |
| Subtraction | a - b | a & b are any real number |
| Multiplication | a * b | a & b are any real number |
| Division | a / b | a & b are any real number |

### Area

| Formula | Equation | Description |
| ------- | -------- | ----------- |
| Square | A = s<sup>2</sup> | where s = any side of the square |
| Rectangle | A = lw | where l = length and w = width |
| Parallelogram | A = bh | where b = base and h = height |
| Triangle | A = (1/2)bh| where b = base and h = height |
| Circle | A = π r<sup>2</sup> | where π = 3.14 and r = radius |
| Sphere | S = 4 π r<sup>2</sup> | where s = Surface area |

### Surface Area

| Formula | Equation | Description |
| ------- | -------- | ----------- |
| Cube | SA = 6s<sup>2</sup> | where s = any side |
| Cylinder (lateral) | SA = 2 π r h | where π = 3.14, r = radius, and h = height |

### Perimeter

| Formula | Equation | Description |
| ------- | -------- | ----------- |
| Square | P = 4s | where s = any side |
| Rectangle | P = 2l + 2w | where l = length and w = width |
| Triangle | P = s1 + s2 + s3 | where s = a side |
| Circle | C = π d | where π = 3.14 and d = diameter |

### Volume

| Formula | Equation | Description |
| ------- | -------- | ----------- |
| Cube | V = S<sup>3</sup> | where S = any side |
| Rectangular Container | V = lwh | where l = length, w = width, and h = height |
| Cylinder | V = π r<sup>2</sup>h | where π= 3.14, r = radius, and h = height |

## Instructions

1. Fork and clone the repository as usual
2. Open the lab in your favored IDE
3. Complete the functions to return the proper values
4. Open a browser and use the Dev Tools to test your
5. After all functions are complete, push to GitHub and create a pull request
16 changes: 16 additions & 0 deletions RR-JS-Basics/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Basic Formulas</title>
<script src="./js/formulas.js" charset="utf-8"></script>
</head>
<body>
<h1>Basic Formulas</h1>
<ol>
<li>Open Developer Tools</li>
<li>Select the Console Tab</li>
<li>Begin typing JS functions to test output</li>
</ol>
</body>
</html>
100 changes: 100 additions & 0 deletions RR-JS-Basics/js/formulas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Basic math formulaas
function addition(num1, num2){
let sum = num1 + num2;
return sum;
}

function subtraction(num1, num2){
let difference = num1 - num2;
return difference;
}

function multiplication(num1, num2){
let product = num1 * num2;
return product;
}

function division(num1, num2){
let quotient = num1 / num2;
return quotient;
}

// Area formulaas
function areaSquare(side){
let areaSquare = Math.pow(side, 2);
return areaSquare;
}

function areaRectangle(length, width){
let areaRectangle = length * width;
return areaRectangle;
}

function areaParallelogram(base, height){
let areaParallelogram = base * height;
return areaParallelogram;
}

function areaTriangle(base, height){
let areaTriangle = (1/2) * base * height;
return areaTriangle;
}

//Did not use Math.PI because it resulted in slightly different numbers from using 3.14 on the directions page.
function Circle(radius){
let Circle = Math.pow(radius, 2) * 3.14;
return Circle;
}

function Sphere(radius){
let Sphere = 4 * 3.14 * Math.pow(radius, 2);
return Sphere;
}

// Surface Area formulas
function surfaceAreaCube(side){
let areaCube = Math.pow(side, 2) * 6;
return areaCube;
}

function surfaceAreaCylinder(radius, height){
let = areaCylinder = 2 * 3.14 * radius * height;
return areaCylinder;
}

// Perimeter formulas
function perimeterSquare(side){
let perimeterSquare = 4 * side;
return perimeterSquare;
}

function perimeterRectangle(length, height){
let perimeterRectangle = (2 * length) + (2 * height);
return perimeterRectangle;
}

function perimeterTriangle(side1, side2, side3){
let perimeterTriangle = side1 + side2 +side3;
return perimeterTriangle;
}

function perimeterCircle(diameter){
let perimeterCircle= 3.14 * diameter;
return perimeterCircle;
}

// Volume formulas
function volumeCube(side){
let volumeCube = Math.pow(side, 3);
return volumeCube;
}

function volumeRectangular(length, width, height){
let volumeRectangular = length * width * height;
return volumeRectangular;
}

function volumeCylinder(radius, height){
let volumeCylinder = 3.14 * Math.pow(radius, 2) * height;
return volumeCylinder;
}