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
109 changes: 109 additions & 0 deletions formulas1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// basic Math

let points = 10;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove testing logic after you finish

let xpoints = 7;

points += xpoints;
console.log(points);

let donuts = 30;
let ateDonuts = 10;

donuts -= ateDonuts;
console.log(donuts);




function addition(a, b ){
return a + b;
}

function subtraction(){
return a - b;
}

function multiplication(a, b){
return a * b;
}

function division( a, b){
return a / b;
}

//Area

let side = 4;
function areaSquare(side){
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to use the parameter side (-3)

return Math.pow(4, 2);
}

function areaRectangle(length, width){
return length * width;

}

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

function areaTriangle(base, height){
return (base * height) / 2;


}

function areaCircle(radius){
return Math.PI * (radius * radius);

}

function areaSphere(radius){
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't run since math was not capitalized (-1)

return 4 * Math.PI * (math.pow(radius, 2));

}

// surface area
let side = 4;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let side = 4 is not needed

function surfaceAreaCube(side){
return 6 * Math.pow(side, 2);
}

function surfaceAreaCylinder(PI, radius, height){
return 2 * Math.PI * (radius * height);

}

// Perimeter

function perimeterSquare(side){
return 4 * side;
}

function perimeterRectangle(length, width){
return 2 * length + 2 * width;
}

function perimeterTriangle(side, side, side){
return side * 1 + side * 2 + side * 3;


}

function perimeterCircle(PI, diameter){
return Math.PI * diameter;
}

// volume

function volumeCube(side){
return Math.pow(side, 3);
}

function volumeRectangularContainer(length, width, height){
return length * width * height;
}

function volumeCylinder(radius, height){
return Math.PI * Math.pow(radius, 2) * height;
}
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>Basic Formulas</title>
<script src="./js/formulas.js" charset="utf-8"></script>
<script src="./js/formulas1.js" charset="utf-8"></script>
</head>
<body>
<h1>Basic Formulas</h1>
Expand Down