From 73ff692707ed4f019de6112e7fac528360a2d75c Mon Sep 17 00:00:00 2001 From: zalbright90 <61331268+zalbright90@users.noreply.github.com> Date: Mon, 15 Jul 2024 20:07:43 -0700 Subject: [PATCH] Refactor formatDisplay for better readability --- main.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index 3829a68..1c36209 100644 --- a/main.js +++ b/main.js @@ -16,12 +16,17 @@ document.addEventListener('DOMContentLoaded', function() { displayValue = ""; } displayValue += value; - if (displayValue.length > MAX_DISPLAY_LENGTH) { - displayValue = parseFloat(displayValue).toExponential(MAX_DISPLAY_LENGTH - 7); - } + displayValue = formatDisplay(displayValue); displayOutput.textContent = displayValue; } + function formatDisplay(value) { + if (value.length > MAX_DISPLAY_LENGTH) { + return parseFloat(displayValue).toExponential(MAX_DISPLAY_LENGTH - 7); + } + return value; + } + function resetDisplay() { displayValue = ""; calculationJustCompleted = false;