From 42acd7f66bf942850db10689e2644aaf169d57a2 Mon Sep 17 00:00:00 2001 From: 4621553 Date: Sun, 19 Feb 2023 13:45:21 -0600 Subject: [PATCH 1/2] added function --- index.html | 8 ++++---- main.js | 23 ++++++++++++++--------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/index.html b/index.html index 063ab98..befa8b5 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - + Document @@ -18,9 +18,9 @@ - - - + + +
diff --git a/main.js b/main.js index bf60c18..48a2978 100644 --- a/main.js +++ b/main.js @@ -30,15 +30,20 @@ const subtract = (numA, numB) => { // These variables are already defined but that don't point to functions. It's up to you to build the functions to complete your calculator use: const multiply = (numA, numB) => { - // * to get a product then return it - // Open up the inspector tool in Chrome and select the Console tab to see what this functions is "logging out" to the console. - console.log(numA, numB) + const multiply = numA * numB + return multiply +} + +const divide = (numA, numB) => { + const divide = numA / numB + return divide } -const divide = null -// / to get a quotient, -const modulus = null +const modulus = (numA, numB) => { + const modulus = numA % numB + return modulus +} // and % to get a remainder. // This function changes the "operation" variable to be equal to the "id" of the button we choose on the web page. @@ -64,11 +69,11 @@ const equals = () => { break; case "subtraction": putResultInElement(subtract(firstNum, secondNum)) break; - case "multiplication": multiply(firstNum, secondNum) + case "multiplication": putResultInElement(multiply(firstNum, secondNum)) break; - case "division": console.log(divide(firstNum, secondNum)) + case "division": putResultInElement(divide(firstNum, secondNum)) break; - case "modulus": console.log(modulus(firstNum, secondNum)) + case "modulus": putResultInElement(modulus(firstNum, secondNum)) break; default: "Choose an operation" } From 94e516c05365832e3cbde7eb55d4d19fdf54dc60 Mon Sep 17 00:00:00 2001 From: 4621553 Date: Sun, 19 Feb 2023 14:04:12 -0600 Subject: [PATCH 2/2] added clear function --- index.html | 4 ++-- main.js | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index befa8b5..c5135cb 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ - Document + Calculator
@@ -25,7 +25,7 @@
- +
diff --git a/main.js b/main.js index 48a2978..08711e7 100644 --- a/main.js +++ b/main.js @@ -79,3 +79,10 @@ const equals = () => { } } +const clearResults = () => { + console.log("help") + document.getElementById('result').innerHTML = null + document.getElementById('first-Number').value = null + document.getElementById('second-Number').value = null +} +