From 700ef7cbd12c6259f88942d321d8df6764c4d8a8 Mon Sep 17 00:00:00 2001 From: cheeks <134818917+leftovertoast@users.noreply.github.com> Date: Thu, 2 Jan 2025 19:06:41 -0500 Subject: [PATCH] Completed Work With Numbers Exercise --- Murach/exercises/ch02/numbers/index.html | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Murach/exercises/ch02/numbers/index.html b/Murach/exercises/ch02/numbers/index.html index a4ac053..d9eb5a4 100644 --- a/Murach/exercises/ch02/numbers/index.html +++ b/Murach/exercises/ch02/numbers/index.html @@ -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 \ No newline at end of file