Completed Work With Numbers Exercise
This commit is contained in:
parent
c2e4dbba01
commit
700ef7cbd1
@ -8,16 +8,22 @@
|
||||
"use strict";
|
||||
|
||||
// get the length of side A and B
|
||||
|
||||
const sideA = prompt("Enter length of A: ");
|
||||
const sideB = prompt ("Enter length of B:");
|
||||
// calculate the perimeter of the rectangle
|
||||
|
||||
const perimeterOfRectangle = 2 * (parseInt(sideA) + parseInt(sideB));
|
||||
console.log("Perimeter: " + perimeterOfRectangle);
|
||||
// calculate the area of the rectangle
|
||||
|
||||
const areaOfRectangle = parseInt(sideA) * parseInt(sideB);
|
||||
console.log("Area: " + areaOfRectangle);
|
||||
// get the hypotenuse of the right triangle
|
||||
// c = sqrt(a^2 + b^2)
|
||||
const hypo = Math.sqrt((Math.pow(parseInt(sideA), 2)) + (Math.pow(parseInt(sideB), 2)));
|
||||
console.log("Hypotenuse: " + hypo.toFixed(4));
|
||||
// pythagorean theorem : c = sqrt(a^2 + b^2)
|
||||
|
||||
// display the results to the user
|
||||
|
||||
//completed in steps above
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user