From 8465f43900ad6b2fb489fc86dc3a88348437b4f7 Mon Sep 17 00:00:00 2001 From: Seung-Gi0301 Date: Wed, 11 Oct 2023 10:52:43 +0900 Subject: [PATCH] [NC] Decimal Result DONE --- index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index fc084d6..ab55266 100644 --- a/index.js +++ b/index.js @@ -12,9 +12,11 @@ const typeNumberMatchingError = [ function onFormSubmit(event) { event.preventDefault(); - console.log(typeof fromNumber.value); console.log("DECIMAL RESULT: " + calculateDecimal(fromNumber.value)); + decimalResult = calculateDecimal(fromNumber.value); + console.log("TOTAL RESULT: " + calculateResult(decimalResult, toType.value)); } + function calculateDecimal(fromNumber) { event.preventDefault(); if (fromType.value === "Binary") { @@ -87,7 +89,6 @@ function binaryToDecimal(b) { } return d; } - function octalToDecimal(o) { d = 0; o = o.toString(); @@ -96,5 +97,10 @@ function octalToDecimal(o) { } return d; } +function calculateResult(inputDecimal, outputType) { + if (outputType == "Decimal") { + return inputDecimal; + } +} form.addEventListener("submit", onFormSubmit);