-
Notifications
You must be signed in to change notification settings - Fork 75
js basic lab #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
js basic lab #19
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| // basic Math | ||
|
|
||
| let points = 10; | ||
| 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){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won't run since |
||
| return 4 * Math.PI * (math.pow(radius, 2)); | ||
|
|
||
| } | ||
|
|
||
| // surface area | ||
| let side = 4; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| 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; | ||
| } | ||
There was a problem hiding this comment.
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